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/interfaces EmbeddedAnt.java
Date Thu, 13 Jun 2002 01:43:15 GMT
donaldp     2002/06/12 18:43:15

  Modified:    container/src/test/org/apache/myrmidon/components
                        AbstractComponentTest.java
               container/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java
               container/src/test/org/apache/myrmidon/components/embeddor/test
                        DefaultEmbeddorTest.java
               container/src/java/org/apache/myrmidon/interfaces/executor
                        DefaultExecutionFrame.java ExecutionFrame.java
               container/src/java/org/apache/myrmidon/components/executor
                        DefaultExecutor.java
               container/src/java/org/apache/myrmidon/components/workspace
                        DefaultTaskContext.java
               container/src/java/org/apache/myrmidon/interfaces
                        EmbeddedAnt.java
  Log:
  Make the frame responsible for creating the TaskContext
  
  Remove the utility method for aquiring TaskEventManager from frame and go via ServiceManager
instead
  
  Revision  Changes    Path
  1.46      +2 -3      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java
  
  Index: AbstractComponentTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- AbstractComponentTest.java	9 Jun 2002 13:13:54 -0000	1.45
  +++ AbstractComponentTest.java	13 Jun 2002 01:43:14 -0000	1.46
  @@ -40,7 +40,6 @@
   import org.apache.myrmidon.components.property.DefaultPropertyStore;
   import org.apache.myrmidon.components.role.DefaultRoleManager;
   import org.apache.myrmidon.components.type.DefaultTypeManager;
  -import org.apache.myrmidon.components.workspace.DefaultTaskContext;
   import org.apache.myrmidon.interfaces.builder.ModelBuilder;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
   import org.apache.myrmidon.interfaces.converter.ConverterRegistry;
  @@ -245,7 +244,7 @@
           throws Exception
       {
           final ExecutionFrame frame = createExecutionFrame( null );
  -        return new DefaultTaskContext( frame, "test", "gen:///test:0:0" );
  +        return frame.createTaskContext( "test", "gen:///test:0:0" );
       }
   
       /**
  
  
  
  1.89      +2 -2      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.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- DefaultEmbeddor.java	11 Jun 2002 07:45:11 -0000	1.88
  +++ DefaultEmbeddor.java	13 Jun 2002 01:43:14 -0000	1.89
  @@ -183,7 +183,7 @@
           // create the root execution frame
           m_rootProps = createBaseStore( m_serviceManager );
           m_rootFrame = new DefaultExecutionFrame( "", new File( "." ), m_serviceManager
);
  -        m_rootContext = new DefaultTaskContext( m_rootFrame, "<init>", "<init>"
);
  +        m_rootContext = m_rootFrame.createTaskContext( "<init>", "<init>" );
       }
   
       public void start()
  
  
  
  1.32      +5 -4      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/embeddor/test/DefaultEmbeddorTest.java
  
  Index: DefaultEmbeddorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/embeddor/test/DefaultEmbeddorTest.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- DefaultEmbeddorTest.java	11 Jun 2002 07:45:11 -0000	1.31
  +++ DefaultEmbeddorTest.java	13 Jun 2002 01:43:14 -0000	1.32
  @@ -15,12 +15,11 @@
   import org.apache.myrmidon.LogMessageTracker;
   import org.apache.myrmidon.api.event.TaskListener;
   import org.apache.myrmidon.api.metadata.ModelElement;
  -import org.apache.myrmidon.interfaces.oldmodel.Project;
   import org.apache.myrmidon.components.embeddor.DefaultEmbeddor;
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
  +import org.apache.myrmidon.interfaces.event.TaskEventManager;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
  -import org.apache.myrmidon.interfaces.oldmodel.Target;
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   
   /**
  @@ -133,7 +132,9 @@
   
           // Install a listener
           final LogMessageTracker listener = new LogMessageTracker();
  -        frame.getTaskEventManager().addTaskListener( listener );
  +        final TaskEventManager taskEventManager =
  +            (TaskEventManager)frame.getServiceManager().lookup( TaskEventManager.ROLE );
  +        taskEventManager.addTaskListener( listener );
   
           listener.addExpectedMessage( "main-target", "A log message" );
   
  
  
  
  1.6       +15 -18    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/executor/DefaultExecutionFrame.java
  
  Index: DefaultExecutionFrame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/executor/DefaultExecutionFrame.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultExecutionFrame.java	7 Jun 2002 05:43:42 -0000	1.5
  +++ DefaultExecutionFrame.java	13 Jun 2002 01:43:14 -0000	1.6
  @@ -8,10 +8,12 @@
   package org.apache.myrmidon.interfaces.executor;
   
   import java.io.File;
  -import org.apache.avalon.framework.service.ServiceManager;
  -import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.DefaultServiceManager;
  -import org.apache.myrmidon.interfaces.event.TaskEventManager;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.myrmidon.api.TaskContext;
  +import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.components.workspace.DefaultTaskContext;
   import org.apache.myrmidon.interfaces.property.PropertyStore;
   
   /**
  @@ -26,7 +28,6 @@
       private final String m_name;
       private final File m_baseDirectory;
       private final ServiceManager m_serviceManager;
  -    private final TaskEventManager m_eventManager;
   
       public DefaultExecutionFrame( final String name,
                                     final File baseDirectory,
  @@ -35,14 +36,6 @@
           m_name = name;
           m_baseDirectory = baseDirectory;
           m_serviceManager = serviceManager;
  -        try
  -        {
  -            m_eventManager = (TaskEventManager)serviceManager.lookup( TaskEventManager.ROLE
);
  -        }
  -        catch( final ServiceException se )
  -        {
  -            throw new IllegalStateException( se.toString() );
  -        }
       }
   
       /**
  @@ -72,12 +65,16 @@
       }
   
       /**
  -     * Returns the {@link TaskEventManager} that can be used to fire events
  -     * or to register listeners.
  +     * Create a {@link TaskContext} object for current frame.
  +     *
  +     * @param taskName the name of task
  +     * @param location the location of task
  +     * @return the new TaskContext
        */
  -    public TaskEventManager getTaskEventManager()
  +    public TaskContext createTaskContext( String taskName, String location )
  +        throws TaskException
       {
  -        return m_eventManager;
  +        return new DefaultTaskContext( this, taskName, location );
       }
   
       /**
  @@ -135,6 +132,6 @@
   
       public String toString()
       {
  -        return "Frame: "+ getName() + ",id=" + System.identityHashCode( this );
  +        return "Frame: " + getName() + ",id=" + System.identityHashCode( this );
       }
   }
  
  
  
  1.17      +11 -6     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/executor/ExecutionFrame.java
  
  Index: ExecutionFrame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/executor/ExecutionFrame.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ExecutionFrame.java	28 May 2002 03:29:56 -0000	1.16
  +++ ExecutionFrame.java	13 Jun 2002 01:43:14 -0000	1.17
  @@ -7,10 +7,11 @@
    */
   package org.apache.myrmidon.interfaces.executor;
   
  +import java.io.File;
   import org.apache.avalon.framework.service.ServiceManager;
  -import org.apache.myrmidon.interfaces.event.TaskEventManager;
  +import org.apache.myrmidon.api.TaskContext;
  +import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.interfaces.property.PropertyStore;
  -import java.io.File;
   
   /**
    * An Execution Frame represents the scope in which tasks are executed.
  @@ -52,10 +53,14 @@
       ServiceManager getServiceManager();
   
       /**
  -     * Returns the {@link TaskEventManager} that can be used to fire events
  -     * or to register listeners.
  +     * Create a {@link TaskContext} object for current frame.
  +     *
  +     * @param taskName the name of task
  +     * @param location the location of task
  +     * @return the new TaskContext
        */
  -    TaskEventManager getTaskEventManager();
  +    TaskContext createTaskContext( String taskName, String location )
  +        throws TaskException;
   
       /**
        * Create a child execution frame.
  
  
  
  1.45      +27 -8     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java
  
  Index: DefaultExecutor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutor.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- DefaultExecutor.java	5 Jun 2002 07:40:40 -0000	1.44
  +++ DefaultExecutor.java	13 Jun 2002 01:43:15 -0000	1.45
  @@ -10,13 +10,14 @@
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.myrmidon.api.Task;
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.myrmidon.api.event.TaskEvent;
   import org.apache.myrmidon.api.event.LogLevel;
  +import org.apache.myrmidon.api.event.TaskEvent;
   import org.apache.myrmidon.api.metadata.ModelElement;
  -import org.apache.myrmidon.components.workspace.DefaultTaskContext;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
   import org.apache.myrmidon.interfaces.event.TaskEventManager;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
  @@ -43,7 +44,7 @@
       public void execute( final ModelElement taskModel, final ExecutionFrame frame )
           throws TaskException
       {
  -        final TaskEventManager eventManager = frame.getTaskEventManager();
  +        final TaskEventManager eventManager = getTaskEventManager( frame );
           final String taskName = taskModel.getName();
           final String taskPath = frame.getName();
           final String taskLocation = taskModel.getLocation();
  @@ -78,6 +79,27 @@
       }
   
       /**
  +     * Get TaskEventManager from frame.
  +     *
  +     * @param frame the frame
  +     * @return the event Manager
  +     * @throws TaskException if error occurs aquiring manager
  +     */
  +    private TaskEventManager getTaskEventManager( final ExecutionFrame frame )
  +        throws TaskException
  +    {
  +        final ServiceManager serviceManager = frame.getServiceManager();
  +        try
  +        {
  +            return (TaskEventManager)serviceManager.lookup( TaskEventManager.ROLE );
  +        }
  +        catch( final ServiceException se )
  +        {
  +            throw new TaskException( se.getMessage(), se );
  +        }
  +    }
  +
  +    /**
        * Actually execute task by
        *
        * <ul>
  @@ -151,9 +173,7 @@
       {
           // TODO - need to deactivate the context once the task has finished
           // executing
  -        return new DefaultTaskContext( frame,
  -                                       taskModel.getName(),
  -                                       taskModel.getLocation() );
  +        return frame.createTaskContext( taskModel.getName(), taskModel.getName() );
       }
   
       /**
  @@ -195,7 +215,6 @@
               throw new TaskException( message, throwable );
           }
       }
  -
   
       /**
        * Configures a task instance.
  
  
  
  1.53      +3 -21     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java
  
  Index: DefaultTaskContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultTaskContext.java,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- DefaultTaskContext.java	9 Jun 2002 23:49:24 -0000	1.52
  +++ DefaultTaskContext.java	13 Jun 2002 01:43:15 -0000	1.53
  @@ -124,29 +124,11 @@
           final ServiceManager serviceManager = m_frame.getServiceManager();
           try
           {
  -/*
  -            // Map the service class to the role name for that service
  -            final RoleManager roleManager = (RoleManager)serviceManager.lookup( RoleManager.ROLE
);
  -            final RoleInfo roleInfo = roleManager.getRoleByImplementationClass( clazz );
  -
  -            // If the role is not found, use the classname
  -            final String roleName;
  -            if( roleInfo != null )
  -            {
  -                roleName = roleInfo.getName();
  -            }
  -            else
  -            {
  -                roleName = classname;
  -            }
  -*/
  -
  -            final String roleName = classname;
               // Lookup the service by role name.  Note that this will chain
               // up to parent ServiceManagers (if any)
  -            if( serviceManager.hasService( roleName ) )
  +            if( serviceManager.hasService( classname ) )
               {
  -                return serviceManager.lookup( roleName );
  +                return serviceManager.lookup( classname );
               }
           }
           catch( final ServiceException e )
  
  
  
  1.24      +3 -2      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.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- EmbeddedAnt.java	11 Jun 2002 07:45:11 -0000	1.23
  +++ EmbeddedAnt.java	13 Jun 2002 01:43:15 -0000	1.24
  @@ -301,7 +301,8 @@
                                      final ExecutionFrame frame )
           throws Exception
       {
  -        final TaskEventManager eventManager = frame.getTaskEventManager();
  +        final TaskEventManager eventManager =
  +            (TaskEventManager)frame.getServiceManager().lookup( TaskEventManager.ROLE );
           final int count = m_listeners.size();
           for( int i = 0; i < count; i++ )
           {
  
  
  

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