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/service MultiSourceServiceManager.java
Date Tue, 28 May 2002 03:29:57 GMT
donaldp     02/05/27 20:29:57

  Modified:    container/src/test/org/apache/myrmidon/components
                        AbstractComponentTest.java
               container/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java
               container/src/java/org/apache/myrmidon/interfaces/executor
                        DefaultExecutionFrame.java ExecutionFrame.java
               container/src/java/org/apache/myrmidon/interfaces/service
                        MultiSourceServiceManager.java
  Log:
  ExecutionFrame no longer needs to store a Logger.
  
  It also chooses to extract the PropertyStore and TaskEventManager from the ServiceManager
rather than requiring them be passed in. This means that PropertyStore is now a Service.
  
  This also highlights the need for a real service kernel to be implemented and soon.
  
  Revision  Changes    Path
  1.43      +9 -14     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.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- AbstractComponentTest.java	27 May 2002 08:30:30 -0000	1.42
  +++ AbstractComponentTest.java	28 May 2002 03:29:56 -0000	1.43
  @@ -23,7 +23,6 @@
   import org.apache.avalon.framework.logger.LogEnabled;
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.service.DefaultServiceManager;
  -import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.myrmidon.AbstractContainerTestCase;
   import org.apache.myrmidon.api.TaskContext;
  @@ -62,7 +61,7 @@
    * A base class for tests for the default components.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.42 $ $Date: 2002/05/27 08:30:30 $
  + * @version $Revision: 1.43 $ $Date: 2002/05/28 03:29:56 $
    */
   public abstract class AbstractComponentTest
       extends AbstractContainerTestCase
  @@ -77,7 +76,7 @@
       /**
        * Returns the component manager containing the components to test.
        */
  -    protected final ServiceManager getServiceManager() throws Exception
  +    protected final DefaultServiceManager getServiceManager() throws Exception
       {
           if( m_serviceManager == null )
           {
  @@ -226,11 +225,8 @@
       protected TaskContext createContext()
           throws Exception
       {
  -        ExecutionFrame frame = createExecutionFrame( null );
  -
  -        final TaskContext context =
  -            new DefaultTaskContext( frame, "test", "gen:///test:0:0" );
  -        return context;
  +        final ExecutionFrame frame = createExecutionFrame( null );
  +        return new DefaultTaskContext( frame, "test", "gen:///test:0:0" );
       }
   
       /**
  @@ -239,18 +235,16 @@
       protected ExecutionFrame createExecutionFrame( PropertyStore props )
           throws Exception
       {
  -        final ServiceManager serviceManager = getServiceManager();
  -        final TaskEventManager eventManager = (TaskEventManager)serviceManager.lookup(
TaskEventManager.ROLE );
  +        final DefaultServiceManager serviceManager = getServiceManager();
   
           if( props == null )
           {
               props = new DefaultPropertyStore();
           }
  +        serviceManager.put( PropertyStore.ROLE, props );
   
           final File baseDir = getTestDirectory();
  -        final ExecutionFrame frame =
  -            new DefaultExecutionFrame( "", baseDir, getLogger(), props, serviceManager,
eventManager );
  -        return frame;
  +        return new DefaultExecutionFrame( "", baseDir, serviceManager );
       }
   
       /**
  @@ -259,7 +253,8 @@
       protected void registerRole( final RoleInfo roleInfo )
           throws Exception
       {
  -        RoleRegistry roleRegistry = (RoleRegistry)getServiceManager().lookup( RoleRegistry.ROLE
);
  +        final RoleRegistry roleRegistry =
  +            (RoleRegistry)getServiceManager().lookup( RoleRegistry.ROLE );
           roleRegistry.addRole( roleInfo );
       }
   
  
  
  
  1.77      +19 -23    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.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- DefaultEmbeddor.java	27 May 2002 08:30:30 -0000	1.76
  +++ DefaultEmbeddor.java	28 May 2002 03:29:56 -0000	1.77
  @@ -63,7 +63,7 @@
    * Instantiate this to embed inside other applications.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.76 $ $Date: 2002/05/27 08:30:30 $
  + * @version $Revision: 1.77 $ $Date: 2002/05/28 03:29:56 $
    */
   public class DefaultEmbeddor
       extends AbstractLogEnabled
  @@ -81,7 +81,6 @@
       private Deployer m_deployer;
       private TypeManager m_typeManager;
       private LibraryManager m_libraryManager;
  -    private MultiSourceServiceManager m_workspaceServiceManager;
   
       private List m_components = new ArrayList();
       private DefaultServiceManager m_serviceManager = new DefaultServiceManager();
  @@ -143,19 +142,28 @@
       public ExecutionFrame createExecutionFrame( final Map properties )
           throws Exception
       {
  +        // setup a service manager that creates the project services
  +        final ServiceManager projServiceManager =
  +            (ServiceManager)createService( ServiceManager.class,
  +                                           PREFIX + "service.InstantiatingServiceManager"
);
  +        setupObject( projServiceManager, m_serviceManager, null );
  +        m_components.add( projServiceManager );
  +
  +        final MultiSourceServiceManager msServiceManager =
  +            new MultiSourceServiceManager();
  +        msServiceManager.add( projServiceManager );
  +        msServiceManager.add( m_serviceManager );
  +
  +        final DefaultServiceManager manager =
  +            new DefaultServiceManager( msServiceManager );
  +
           // Create the property store
           final PropertyStore propStore = createBaseStore( properties );
  -
  -        // Create an execution frame, and attach it to the workspace
  -        final TaskEventManager eventManager =
  -            (TaskEventManager)m_workspaceServiceManager.lookup( TaskEventManager.ROLE );
  +        manager.put( PropertyStore.ROLE, propStore );
   
           return new DefaultExecutionFrame( "",
                                             new File( "." ),
  -                                          getLogger(),
  -                                          propStore,
  -                                          m_workspaceServiceManager,
  -                                          eventManager );
  +                                          manager );
       }
   
       /**
  @@ -166,7 +174,7 @@
       {
           final Workspace workspace =
               (Workspace)createService( Workspace.class, PREFIX + "workspace.DefaultWorkspace"
);
  -        setupObject( workspace, m_workspaceServiceManager, null );
  +        setupObject( workspace, null, null );
   
           return workspace;
       }
  @@ -200,18 +208,6 @@
           m_deployer = (Deployer)m_serviceManager.lookup( Deployer.ROLE );
           m_typeManager = (TypeManager)m_serviceManager.lookup( TypeManager.ROLE );
           m_libraryManager = (LibraryManager)m_serviceManager.lookup( LibraryManager.ROLE
);
  -
  -        // setup a service manager that creates the project services
  -        final ServiceManager projServiceManager =
  -            (ServiceManager)createService( ServiceManager.class,
  -                                           PREFIX + "service.InstantiatingServiceManager"
);
  -        setupObject( projServiceManager, m_serviceManager, null );
  -        m_components.add( projServiceManager );
  -
  -        // setup a service manager to be used by workspaces
  -        m_workspaceServiceManager = new MultiSourceServiceManager();
  -        m_workspaceServiceManager.add( projServiceManager );
  -        m_workspaceServiceManager.add( m_serviceManager );
       }
   
       public void start()
  
  
  
  1.4       +30 -42    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultExecutionFrame.java	28 May 2002 02:00:30 -0000	1.3
  +++ DefaultExecutionFrame.java	28 May 2002 03:29:56 -0000	1.4
  @@ -8,8 +8,8 @@
   package org.apache.myrmidon.interfaces.executor;
   
   import java.io.File;
  -import org.apache.avalon.framework.logger.Logger;
   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.myrmidon.interfaces.property.PropertyStore;
  @@ -18,32 +18,31 @@
    * Frames in which tasks are executed.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.3 $ $Date: 2002/05/28 02:00:30 $
  + * @version $Revision: 1.4 $ $Date: 2002/05/28 03:29:56 $
    */
   public class DefaultExecutionFrame
       implements ExecutionFrame
   {
       private final String m_name;
       private final File m_baseDirectory;
  -    private final Logger m_logger;
  -    private final PropertyStore m_propertyStore;
       private final ServiceManager m_serviceManager;
       private final TaskEventManager m_eventManager;
   
       public DefaultExecutionFrame( final String name,
                                     final File baseDirectory,
  -                                  final Logger logger,
  -                                  final PropertyStore propertyStore,
  -                                  final ServiceManager serviceManager,
  -                                  final TaskEventManager eventManager )
  +                                  final ServiceManager serviceManager )
       {
           m_name = name;
           m_baseDirectory = baseDirectory;
  -        m_logger = logger;
  -        m_propertyStore = propertyStore;
           m_serviceManager = serviceManager;
  -        m_eventManager = eventManager;
  -        ( (DefaultServiceManager)serviceManager ).put( PropertyStore.ROLE, propertyStore
);
  +        try
  +        {
  +            m_eventManager = (TaskEventManager)serviceManager.lookup( TaskEventManager.ROLE
);
  +        }
  +        catch( final ServiceException se )
  +        {
  +            throw new IllegalStateException( se.toString() );
  +        }
       }
   
       /**
  @@ -64,14 +63,6 @@
       }
   
       /**
  -     * Returns the logger which is to be supplied to tasks.
  -     */
  -    public Logger getLogger()
  -    {
  -        return m_logger;
  -    }
  -
  -    /**
        * Returns the set of services to use to create, configure, and execute
        * tasks.
        */
  @@ -81,15 +72,7 @@
       }
   
       /**
  -     * Returns the set of properties to be supplied to tasks.
  -     */
  -    public PropertyStore getPropertyStore()
  -    {
  -        return m_propertyStore;
  -    }
  -
  -    /**
  -     * Returns the {@link org.apache.myrmidon.interfaces.event.TaskEventManager} that can
be used to fire events
  +     * Returns the {@link TaskEventManager} that can be used to fire events
        * or to register listeners.
        */
       public TaskEventManager getTaskEventManager()
  @@ -117,31 +100,36 @@
               dir = getBaseDirectory();
           }
   
  -        PropertyStore propertyStore;
  -        if( partition )
  +        ServiceManager serviceManager;
  +        if( newServiceManager != null )
           {
  -            propertyStore = getPropertyStore().createChildStore();
  +            serviceManager = newServiceManager;
           }
           else
           {
  -            propertyStore = getPropertyStore();
  +            serviceManager = getServiceManager();
           }
   
  -        ServiceManager serviceManager;
  -        if( newServiceManager != null )
  +        try
           {
  -            serviceManager = newServiceManager;
  +            if( partition )
  +            {
  +                //What an UGLY Hack!!!
  +                final PropertyStore basePropertyStore =
  +                    (PropertyStore)serviceManager.lookup( PropertyStore.ROLE );
  +                final PropertyStore propertyStore = basePropertyStore.createChildStore();
  +                final DefaultServiceManager defaultServiceManager = new DefaultServiceManager(
serviceManager );
  +                defaultServiceManager.put( PropertyStore.ROLE, propertyStore );
  +                serviceManager = defaultServiceManager;
  +            }
           }
  -        else
  +        catch( final ServiceException se )
           {
  -            serviceManager = getServiceManager();
  +            //throw new IllegalStateException( se.toString() );
           }
   
           return new DefaultExecutionFrame( newName,
                                             dir,
  -                                          getLogger(),
  -                                          propertyStore,
  -                                          serviceManager,
  -                                          getTaskEventManager() );
  +                                          serviceManager );
       }
   }
  
  
  
  1.16      +1 -13     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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ExecutionFrame.java	11 May 2002 12:44:00 -0000	1.15
  +++ ExecutionFrame.java	28 May 2002 03:29:56 -0000	1.16
  @@ -7,7 +7,6 @@
    */
   package org.apache.myrmidon.interfaces.executor;
   
  -import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.myrmidon.interfaces.event.TaskEventManager;
   import org.apache.myrmidon.interfaces.property.PropertyStore;
  @@ -23,7 +22,7 @@
    * a logger.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.15 $ $Date: 2002/05/11 12:44:00 $
  + * @version $Revision: 1.16 $ $Date: 2002/05/28 03:29:56 $
    */
   public interface ExecutionFrame
   {
  @@ -51,17 +50,6 @@
        * tasks.
        */
       ServiceManager getServiceManager();
  -
  -    /**
  -     * Returns the logger which is to be supplied to tasks.
  -     * @todo Remove me
  -     */
  -    Logger getLogger();
  -
  -    /**
  -     * Returns the {@link PropertyStore} to be supplied to tasks.
  -     */
  -    PropertyStore getPropertyStore();
   
       /**
        * Returns the {@link TaskEventManager} that can be used to fire events
  
  
  
  1.7       +3 -3      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/service/MultiSourceServiceManager.java
  
  Index: MultiSourceServiceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/service/MultiSourceServiceManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MultiSourceServiceManager.java	1 Apr 2002 09:56:27 -0000	1.6
  +++ MultiSourceServiceManager.java	28 May 2002 03:29:57 -0000	1.7
  @@ -18,13 +18,13 @@
    * {@link ServiceManager} objects.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.6 $ $Date: 2002/04/01 09:56:27 $
  + * @version $Revision: 1.7 $ $Date: 2002/05/28 03:29:57 $
    */
   public class MultiSourceServiceManager
       implements ServiceManager
   {
  -    private static final Resources REZ
  -        = ResourceManager.getPackageResources( MultiSourceServiceManager.class );
  +    private static final Resources REZ =
  +        ResourceManager.getPackageResources( MultiSourceServiceManager.class );
   
       /** The source service managers, in order. */
       private final ArrayList m_sources = new ArrayList();
  
  
  

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