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/workspace DefaultWorkspace.java
Date Tue, 21 May 2002 05:32:26 GMT
donaldp     02/05/20 22:32:26

  Modified:    container/src/java/org/apache/myrmidon/interfaces/workspace
                        Workspace.java
               container/src/java/org/apache/myrmidon/interfaces
                        EmbeddedAnt.java
               container/src/java/org/apache/myrmidon/components/workspace
                        DefaultWorkspace.java
  Log:
  Workspace no longer maintains frame - rather it is responsibility of the EmbeddedAnt + Embeddor
  
  Revision  Changes    Path
  1.12      +4 -16     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/workspace/Workspace.java
  
  Index: Workspace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/workspace/Workspace.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Workspace.java	11 May 2002 12:44:00 -0000	1.11
  +++ Workspace.java	21 May 2002 05:32:26 -0000	1.12
  @@ -10,12 +10,13 @@
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.api.event.TaskListener;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
  +import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   
   /**
    * This is the abstraction through which Projects are executed.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.11 $ $Date: 2002/05/11 12:44:00 $
  + * @version $Revision: 1.12 $ $Date: 2002/05/21 05:32:26 $
    */
   public interface Workspace
   {
  @@ -23,26 +24,13 @@
       String ROLE = Workspace.class.getName();
   
       /**
  -     * Adds a listener, which receives all task events fired in this workspace.
  -     *
  -     * @param listener the listener
  -     */
  -    void addTaskListener( TaskListener listener );
  -
  -    /**
  -     * Removes a listener.
  -     *
  -     * @param listener the listener
  -     */
  -    void removeTaskListener( TaskListener listener );
  -
  -    /**
        * Executes a target in a particular project.
        *
        * @param project the Project
  +     * @param frame the frame in which target is executed
        * @param target the name of the target
        * @exception TaskException if an error occurs
        */
  -    void executeProject( Project project, String target )
  +    void executeProject( Project project, ExecutionFrame frame, String target )
           throws TaskException;
   }
  
  
  
  1.9       +18 -9     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/EmbeddedAnt.java
  
  Index: EmbeddedAnt.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/EmbeddedAnt.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- EmbeddedAnt.java	21 May 2002 05:21:46 -0000	1.8
  +++ EmbeddedAnt.java	21 May 2002 05:32:26 -0000	1.9
  @@ -15,7 +15,6 @@
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.excalibur.io.FileUtil;
  -import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.activity.Startable;
   import org.apache.avalon.framework.context.Context;
  @@ -29,6 +28,8 @@
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
  +import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
  +import org.apache.myrmidon.interfaces.event.TaskEventManager;
   
   /**
    * A utility class, that takes care of launching Myrmidon, and building and
  @@ -41,7 +42,7 @@
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.8 $ $Date: 2002/05/21 05:21:46 $
  + * @version $Revision: 1.9 $ $Date: 2002/05/21 05:32:26 $
    */
   public class EmbeddedAnt
       extends AbstractLogEnabled
  @@ -189,12 +190,15 @@
           final Embeddor embeddor = prepareEmbeddor( embeddorParameters );
           final Project project = prepareProjectModel( embeddor );
   
  +        final ExecutionFrame frame =
  +            embeddor.createExecutionFrame( m_workspaceProperties );
  +        prepareListeners( embeddor, frame );
  +
           // Create a new workspace
           final Workspace workspace = embeddor.createWorkspace( m_workspaceProperties );
  -        prepareListeners( embeddor, workspace );
   
           //execute the project
  -        executeTargets( workspace, project, targets );
  +        executeTargets( workspace, frame, project, targets );
       }
   
       /**
  @@ -221,20 +225,23 @@
        * Actually do the build.
        */
       private void executeTargets( final Workspace workspace,
  +                                 final ExecutionFrame frame,
                                    final Project project,
                                    final String[] targets )
           throws TaskException
       {
  +        //project.execute(frame,);
  +
           //if we didn't specify a target, then choose default
           if( targets == null || targets.length == 0 )
           {
  -            workspace.executeProject( project, project.getDefaultTargetName() );
  +            workspace.executeProject( project, frame, project.getDefaultTargetName() );
           }
           else
           {
               for( int i = 0; i < targets.length; i++ )
               {
  -                workspace.executeProject( project, targets[ i ] );
  +                workspace.executeProject( project, frame, targets[ i ] );
               }
           }
       }
  @@ -314,23 +321,25 @@
           return (Embeddor)clazz.newInstance();
       }
   
  +
       /**
        * Prepares and returns the project listener to use.
        */
       private void prepareListeners( final Embeddor embeddor,
  -                                   final Workspace workspace )
  +                                   final ExecutionFrame frame )
           throws Exception
       {
  +        final TaskEventManager eventManager = frame.getTaskEventManager();
           if( m_listenerName != null )
           {
               final TaskListener listener = embeddor.createListener( m_listenerName );
  -            workspace.addTaskListener( listener );
  +            eventManager.addTaskListener( listener );
           }
           final int count = m_listeners.size();
           for( int i = 0; i < count; i++ )
           {
               final TaskListener listener = (TaskListener)m_listeners.get( i );
  -            workspace.addTaskListener( listener );
  +            eventManager.addTaskListener( listener );
           }
       }
   
  
  
  
  1.63      +28 -50    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java
  
  Index: DefaultWorkspace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- DefaultWorkspace.java	21 May 2002 05:11:18 -0000	1.62
  +++ DefaultWorkspace.java	21 May 2002 05:32:26 -0000	1.63
  @@ -14,10 +14,8 @@
   import org.apache.avalon.framework.service.DefaultServiceManager;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.myrmidon.api.event.TaskListener;
   import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
  -import org.apache.myrmidon.interfaces.event.TaskEventManager;
   import org.apache.myrmidon.interfaces.executor.ExecutionContainer;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.executor.Executor;
  @@ -31,7 +29,7 @@
    * This is the default implementation of Workspace.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.62 $ $Date: 2002/05/21 05:11:18 $
  + * @version $Revision: 1.63 $ $Date: 2002/05/21 05:32:26 $
    */
   public class DefaultWorkspace
       extends AbstractLogEnabled
  @@ -50,28 +48,6 @@
   
       /** A map from Project object -> ProjectEntry for that project. */
       private HashMap m_entries = new HashMap();
  -    private ExecutionFrame m_frame;
  -    private TaskEventManager m_eventManager;
  -
  -    /**
  -     * Add a listener to project events.
  -     *
  -     * @param listener the listener
  -     */
  -    public void addTaskListener( final TaskListener listener )
  -    {
  -        m_eventManager.addTaskListener( listener );
  -    }
  -
  -    /**
  -     * Remove a listener from project events.
  -     *
  -     * @param listener the listener
  -     */
  -    public void removeTaskListener( final TaskListener listener )
  -    {
  -        m_eventManager.removeTaskListener( listener );
  -    }
   
       /**
        * Sets the root execution frame.
  @@ -79,9 +55,7 @@
       public void setRootExecutionFrame( final ExecutionFrame frame )
           throws Exception
       {
  -        m_frame = frame;
           final ServiceManager serviceManager = frame.getServiceManager();
  -        m_eventManager = (TaskEventManager)serviceManager.lookup( TaskEventManager.ROLE
);
           m_typeManager = (TypeManager)serviceManager.lookup( TypeManager.ROLE );
           m_executor = (Executor)serviceManager.lookup( Executor.ROLE );
       }
  @@ -94,23 +68,26 @@
        * @param target the name of the target
        * @exception TaskException if an error occurs
        */
  -    public void executeProject( final Project project, final String target )
  +    public void executeProject( final Project project,
  +                                final ExecutionFrame frame,
  +                                final String target )
           throws TaskException
       {
  -        final ProjectEntry entry = getProjectEntry( project );
  -        executeTarget( entry, target );
  +        final ProjectEntry entry = getProjectEntry( project, frame );
  +        executeTarget( frame, entry, target );
       }
   
       /**
        * Creates an execution frame for a project.
        */
  -    private ExecutionFrame createExecutionFrame( final Project project )
  +    private ExecutionFrame createExecutionFrame( final Project project,
  +                                                 final ExecutionFrame frame )
           throws Exception
       {
           // TODO - move all this stuff to ExecutionFrame.createChildFrame( ..., true ).
   
           final DefaultServiceManager serviceManager =
  -            new DefaultServiceManager( m_frame.getServiceManager() );
  +            new DefaultServiceManager( frame.getServiceManager() );
   
           //Add in child type manager so each frame can register different
           //sets of tasks etc
  @@ -122,7 +99,7 @@
           //We need to create a new deployer so that it deploys
           //to project specific TypeManager
           final Deployer parentDeployer =
  -            (Deployer)m_frame.getServiceManager().lookup( Deployer.ROLE );
  +            (Deployer)frame.getServiceManager().lookup( Deployer.ROLE );
           final Deployer deployer =
               parentDeployer.createChildDeployer( serviceManager );
           serviceManager.put( Deployer.ROLE, deployer );
  @@ -133,16 +110,14 @@
           serviceManager.put( Workspace.ROLE, this );
           serviceManager.put( Project.ROLE, project );
   
  -        final ExecutionFrame frame =
  -            m_frame.createChildFrame( project.getName(),
  -                                      project.getBaseDirectory(),
  -                                      serviceManager,
  -                                      true );
  -
  -        return frame;
  +        return frame.createChildFrame( project.getName(),
  +                                       project.getBaseDirectory(),
  +                                       serviceManager,
  +                                       true );
       }
   
  -    private ProjectEntry getProjectEntry( final Project project )
  +    private ProjectEntry getProjectEntry( final Project project,
  +                                          final ExecutionFrame frame )
           throws TaskException
       {
           ProjectEntry entry = (ProjectEntry)m_entries.get( project.getURI() );
  @@ -150,8 +125,9 @@
           {
               try
               {
  -                final ExecutionFrame frame = createExecutionFrame( project );
  -                entry = new ProjectEntry( project, frame );
  +                final ExecutionFrame projectFrame =
  +                    createExecutionFrame( project, frame );
  +                entry = new ProjectEntry( project, projectFrame );
                   m_entries.put( project.getURI(), entry );
               }
               catch( Exception e )
  @@ -185,7 +161,8 @@
        * @param targetName the name of the target to execute
        * @exception TaskException if an error occurs
        */
  -    private void executeTarget( final ProjectEntry entry,
  +    private void executeTarget( final ExecutionFrame frame,
  +                                final ProjectEntry entry,
                                   final String targetName )
           throws TaskException
       {
  @@ -197,7 +174,7 @@
               throw new TaskException( message );
           }
   
  -        executeTarget( entry, targetName, target );
  +        executeTarget( frame, entry, targetName, target );
       }
   
       /**
  @@ -210,7 +187,8 @@
        * @param entry the project in which to execute
        * @exception TaskException if an error occurs
        */
  -    private void executeTarget( final ProjectEntry entry,
  +    private void executeTarget( final ExecutionFrame frame,
  +                                final ProjectEntry entry,
                                   final String name,
                                   final Target target )
           throws TaskException
  @@ -240,7 +218,7 @@
           // Implicit target first
           if( target != project.getImplicitTarget() )
           {
  -            executeTarget( entry, IMPLICIT_TARGET_NAME, project.getImplicitTarget() );
  +            executeTarget( frame, entry, IMPLICIT_TARGET_NAME, project.getImplicitTarget()
);
           }
   
           // Named dependencies
  @@ -253,13 +231,13 @@
               {
                   // Dependency in a referenced project
                   final Project otherProject = getProject( otherProjectName, project );
  -                final ProjectEntry otherEntry = getProjectEntry( otherProject );
  -                executeTarget( otherEntry, dependency.getTargetName() );
  +                final ProjectEntry otherEntry = getProjectEntry( otherProject, frame );
  +                executeTarget( frame, otherEntry, dependency.getTargetName() );
               }
               else
               {
                   // Dependency in this project
  -                executeTarget( entry, dependency.getTargetName() );
  +                executeTarget( frame, entry, dependency.getTargetName() );
               }
           }
   
  
  
  

--
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