ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor DefaultEmbeddor.java
Date Sun, 09 Jun 2002 03:34:46 GMT
donaldp     2002/06/08 20:34:46

  Modified:    container/src/java/org/apache/myrmidon/components/builder
                        DefaultProjectBuilder.java Resources.properties
               container/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java
  Added:       container/src/java/org/apache/myrmidon/components/builder
                        MasterProjectBuilder.java
  Log:
  Create a MasterProjectBuilder that is responsible for delegating to the correct ProjectBuilder
rather than hardwiring this behaviour into Embeddor.
  
  Revision  Changes    Path
  1.69      +6 -5      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java
  
  Index: DefaultProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- DefaultProjectBuilder.java	8 Jun 2002 23:56:04 -0000	1.68
  +++ DefaultProjectBuilder.java	9 Jun 2002 03:34:46 -0000	1.69
  @@ -23,18 +23,18 @@
   import org.apache.myrmidon.interfaces.builder.ModelBuilder;
   import org.apache.myrmidon.interfaces.builder.ProjectBuilder;
   import org.apache.myrmidon.interfaces.builder.ProjectException;
  +import org.apache.myrmidon.interfaces.embeddor.Embeddor;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
  -import org.apache.myrmidon.interfaces.workspace.ProjectRef;
   import org.apache.myrmidon.interfaces.property.NameValidator;
   import org.apache.myrmidon.interfaces.property.NameValidatorManager;
  -import org.apache.myrmidon.interfaces.embeddor.Embeddor;
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
  +import org.apache.myrmidon.interfaces.workspace.ProjectRef;
   
   /**
    * Default implementation to construct project from a build file.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.68 $ $Date: 2002/06/08 23:56:04 $
  + * @version $Revision: 1.69 $ $Date: 2002/06/09 03:34:46 $
    *
    * @ant.type type="project-builder" name="ant2"
    */
  @@ -146,8 +146,9 @@
           }
           catch( Exception e )
           {
  -            final String message = REZ.getString( "ant.project-build.error",
  -                                                  file.getAbsolutePath() );
  +            final String message =
  +                REZ.getString( "ant.project-build.error",
  +                               file.getAbsolutePath() );
               throw new ProjectException( message, e );
           }
       }
  
  
  
  1.14      +4 -1      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/Resources.properties,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Resources.properties	8 Jun 2002 23:56:04 -0000	1.13
  +++ Resources.properties	9 Jun 2002 03:34:46 -0000	1.14
  @@ -33,4 +33,7 @@
   
   project.unknown-ref.error=Unknown project reference "{0}".
   project.nobuild-project.error=Could not load referenced project "{0}" with type "{1}".
  -project.unknown-target.error=Unknown target "{0}".
  \ No newline at end of file
  +project.unknown-target.error=Unknown target "{0}".
  +
  +builder.create.error=Error creating Project of type "{0}" at "{1}". (Reason: {2})
  +builder.destroy.error=Error destroying builder of type "{0}". (Reason: {1})
  \ No newline at end of file
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/MasterProjectBuilder.java
  
  Index: MasterProjectBuilder.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.myrmidon.components.builder;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.framework.ExceptionUtil;
  import org.apache.avalon.framework.container.ContainerUtil;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.Serviceable;
  import org.apache.myrmidon.interfaces.builder.ProjectBuilder;
  import org.apache.myrmidon.interfaces.builder.ProjectException;
  import org.apache.myrmidon.interfaces.oldmodel.Project;
  import org.apache.myrmidon.interfaces.type.TypeFactory;
  import org.apache.myrmidon.interfaces.type.TypeManager;
  import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
  
  /**
   * This is the project builder that is capable of
   * delegating to arbitrary ProjectBuilders as needed.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/09 03:34:46 $
   */
  public class MasterProjectBuilder
      extends AbstractLogEnabled
      implements ProjectBuilder, Serviceable
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( MasterProjectBuilder.class );
  
      private TypeManager m_typeManager;
      private ServiceManager m_serviceManager;
  
      public void service( ServiceManager manager )
          throws ServiceException
      {
          m_typeManager = (TypeManager)manager.lookup( TypeManager.ROLE );
          m_serviceManager = manager;
      }
  
      public Project build( final ProjectDescriptor project )
          throws ProjectException
      {
          ProjectBuilder builder = null;
          try
          {
              builder = createProjectBuilder( project.getType() );
  
              ContainerUtil.enableLogging( builder, getLogger() );
              ContainerUtil.service( builder, m_serviceManager );
  
              return builder.build( project );
          }
          catch( final Exception e )
          {
              final String message =
                  REZ.getString( "builder.create.error",
                                 project.getType(),
                                 project.getUri(),
                                 ExceptionUtil.printStackTrace( e ) );
              throw new ProjectException( message, e );
          }
          finally
          {
              if( null != builder )
              {
                  try
                  {
                      ContainerUtil.shutdown( builder );
                  }
                  catch( final Exception e )
                  {
                      final String message =
                          REZ.getString( "builder.destroy.error",
                                         project.getType(),
                                         e );
                      getLogger().error( message, e );
                  }
              }
          }
      }
  
      /**
       * Creates a project builder for a project type.
       */
      private ProjectBuilder createProjectBuilder( final String type )
          throws Exception
      {
          final TypeFactory factory = m_typeManager.getFactory( ProjectBuilder.ROLE );
          return (ProjectBuilder)factory.create( type );
      }
  }
  
  
  
  1.84      +7 -28     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java
  
  Index: DefaultEmbeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- DefaultEmbeddor.java	9 Jun 2002 02:45:53 -0000	1.83
  +++ DefaultEmbeddor.java	9 Jun 2002 03:34:46 -0000	1.84
  @@ -16,7 +16,6 @@
   import org.apache.aut.converter.Converter;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.framework.CascadingException;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.activity.Startable;
  @@ -65,7 +64,7 @@
    * Instantiate this to embed inside other applications.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.83 $ $Date: 2002/06/09 02:45:53 $
  + * @version $Revision: 1.84 $ $Date: 2002/06/09 03:34:46 $
    */
   public class DefaultEmbeddor
       extends AbstractLogEnabled
  @@ -91,6 +90,7 @@
       private ExecutionFrame m_rootFrame;
       private TaskContext m_rootContext;
       private PropertyStore m_rootProps;
  +    private ProjectBuilder m_projectBuilder;
   
       /**
        * Setup basic properties of engine.
  @@ -109,32 +109,7 @@
                                     final Parameters parameters )
           throws Exception
       {
  -        try
  -        {
  -            // TODO - reuse the project builders, or dispose them
  -            final ProjectBuilder builder = getProjectBuilder( project.getType(), parameters
);
  -            return builder.build( project );
  -        }
  -        catch( final Exception e )
  -        {
  -            final String message =
  -                REZ.getString( "create-project.error",
  -                               project.getUri() );
  -            throw new CascadingException( message, e );
  -        }
  -    }
  -
  -    /**
  -     * Creates a project builder for a project type.
  -     */
  -    private ProjectBuilder getProjectBuilder( final String type,
  -                                              final Parameters parameters )
  -        throws Exception
  -    {
  -        final TypeFactory factory = m_typeManager.getFactory( ProjectBuilder.ROLE );
  -        final ProjectBuilder builder = (ProjectBuilder)factory.create( type );
  -        setupObject( builder, m_serviceManager, parameters );
  -        return builder;
  +        return m_projectBuilder.build( project );
       }
   
       /**
  @@ -197,6 +172,7 @@
   
           // locate the components we need
           m_deployer = (Deployer)m_serviceManager.lookup( Deployer.ROLE );
  +        m_projectBuilder = (ProjectBuilder)m_serviceManager.lookup( ProjectBuilder.ROLE
);
           m_typeManager = (TypeManager)m_serviceManager.lookup( TypeManager.ROLE );
           m_libraryManager = (LibraryManager)m_serviceManager.lookup( LibraryManager.ROLE
);
           m_configurer = (Configurer)m_serviceManager.lookup( Configurer.ROLE );
  @@ -327,6 +303,9 @@
           createComponent( TaskEventManager.ROLE,
                            TaskEventManager.class,
                            PREFIX + "event.DefaultTaskEventManager" );
  +        createComponent( ProjectBuilder.ROLE,
  +                         ProjectBuilder.class,
  +                         PREFIX + "builder.MasterProjectBuilder" );
   
           m_serviceManager.put( Embeddor.ROLE, this );
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message