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/test/org/apache/myrmidon/components/type/test DefaultTypeManagerTestCase.java
Date Fri, 21 Jun 2002 08:05:35 GMT
donaldp     2002/06/21 01:05:35

  Modified:    container/src/conf ant-services.xml
               container/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java
               container/src/java/org/apache/myrmidon/components/executor
                        DefaultExecutionFrame.java
               container/src/java/org/apache/myrmidon/components/type
                        DefaultTypeManager.java
               container/src/java/org/apache/myrmidon/components/workspace
                        DefaultWorkspace.java
               container/src/test/org/apache/myrmidon/components
                        AbstractComponentTest.java
               container/src/test/org/apache/myrmidon/components/type/test
                        DefaultTypeManagerTestCase.java
  Log:
  Commit some really ugly hacks! Mainly reworking service management so that eventualy we
can kill ExecutionFrame.
  
  Revision  Changes    Path
  1.3       +0 -14     jakarta-ant-myrmidon/container/src/conf/ant-services.xml
  
  Index: ant-services.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/conf/ant-services.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ant-services.xml	21 Jun 2002 02:58:20 -0000	1.2
  +++ ant-services.xml	21 Jun 2002 08:05:34 -0000	1.3
  @@ -1,20 +1,6 @@
   <services>
  -    <service classname="org.apache.myrmidon.components.role.DefaultRoleManager">
  -        <role name="org.apache.myrmidon.interfaces.role.RoleManager"/>
  -        <role name="org.apache.myrmidon.interfaces.role.RoleRegistry"/>
  -    </service>
  -    <service classname="org.apache.myrmidon.components.property.DefaultPropertyStore">
  -        <role name="org.apache.myrmidon.interfaces.property.PropertyStore"/>
  -    </service>
       <service classname="org.apache.myrmidon.components.extensions.DefaultExtensionManager">
           <role name="org.apache.myrmidon.interfaces.extensions.ExtensionManager"/>
  -    </service>
  -    <service classname="org.apache.myrmidon.components.type.DefaultTypeManager">
  -        <role name="org.apache.myrmidon.interfaces.type.TypeManager"/>
  -        <role name="org.apache.myrmidon.interfaces.type.TypeRegistry"/>
  -    </service>
  -    <service classname="org.apache.myrmidon.components.deployer.DefaultDeployer">
  -        <role name="org.apache.myrmidon.interfaces.deployer.Deployer"/>
       </service>
       <service classname="org.apache.myrmidon.components.configurer.DefaultConfigurer">
           <role name="org.apache.myrmidon.interfaces.configurer.Configurer"/>
  
  
  
  1.103     +30 -9     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.102
  retrieving revision 1.103
  diff -u -r1.102 -r1.103
  --- DefaultEmbeddor.java	21 Jun 2002 00:45:16 -0000	1.102
  +++ DefaultEmbeddor.java	21 Jun 2002 08:05:34 -0000	1.103
  @@ -26,7 +26,6 @@
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.service.DefaultServiceManager;
  -import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.myrmidon.Constants;
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
  @@ -34,7 +33,11 @@
   import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.components.executor.DefaultExecutionFrame;
   import org.apache.myrmidon.components.service.InstantiatingServiceManager;
  +import org.apache.myrmidon.components.type.DefaultTypeManager;
   import org.apache.myrmidon.components.workspace.DefaultWorkspace;
  +import org.apache.myrmidon.components.role.DefaultRoleManager;
  +import org.apache.myrmidon.components.property.DefaultPropertyStore;
  +import org.apache.myrmidon.components.deployer.DefaultDeployer;
   import org.apache.myrmidon.interfaces.builder.ProjectBuilder;
   import org.apache.myrmidon.interfaces.configurer.Configurer;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
  @@ -45,12 +48,15 @@
   import org.apache.myrmidon.interfaces.library.LibraryManager;
   import org.apache.myrmidon.interfaces.model.Project;
   import org.apache.myrmidon.interfaces.property.PropertyStore;
  +import org.apache.myrmidon.interfaces.role.RoleManager;
  +import org.apache.myrmidon.interfaces.role.RoleRegistry;
   import org.apache.myrmidon.interfaces.service.DefaultServiceFactory;
   import org.apache.myrmidon.interfaces.service.ServiceDescriptor;
   import org.apache.myrmidon.interfaces.service.ServiceFactory;
   import org.apache.myrmidon.interfaces.service.ServiceRegistry;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeManager;
  +import org.apache.myrmidon.interfaces.type.TypeRegistry;
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
   import org.xml.sax.InputSource;
  @@ -167,19 +173,38 @@
           // setup the root components
           m_serviceManager = new InstantiatingServiceManager( getLogger(), m_context );
           ContainerUtil.enableLogging( m_serviceManager, getLogger() );
  +
           setupComponents();
   
  +        m_rootProps = new DefaultPropertyStore();
  +        ContainerUtil.service( m_rootProps, m_serviceManager );
  +
  +        final RoleManager roleManager = new DefaultRoleManager();
  +        m_typeManager = new DefaultTypeManager( null, roleManager );
  +
  +        m_serviceManager.registerService( new String[]{RoleManager.ROLE, RoleRegistry.ROLE},
  +                                          roleManager );
  +        m_serviceManager.registerService( new String[]{TypeManager.ROLE, TypeRegistry.ROLE},
  +                                          m_typeManager );
  +        m_serviceManager.registerService( new String[]{PropertyStore.ROLE},
  +                                          m_rootProps );
  +
  +        //HACK: Remove me after deployer become unscoped...
  +        final DefaultDeployer deployer = new DefaultDeployer();
  +        ContainerUtil.enableLogging( deployer, getLogger() );
  +        ContainerUtil.service( deployer, m_serviceManager );
  +        m_serviceManager.registerService( new String[]{Deployer.ROLE}, deployer );
  +
           // 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 );
   
           // create the root execution frame
  -        m_rootProps = createBaseStore( m_serviceManager );
           m_rootFrame = new DefaultExecutionFrame( "", new File( "." ), m_serviceManager
);
           m_rootContext = m_rootFrame.createTaskContext( "<init>", "<init>" );
  +        setupBaseStore( m_rootProps );
       }
   
       public void start()
  @@ -347,19 +372,15 @@
       /**
        * Creates a root property store.
        */
  -    private PropertyStore createBaseStore( final ServiceManager serviceManager )
  +    private void setupBaseStore( final PropertyStore store )
           throws Exception
       {
  -        final PropertyStore store = (PropertyStore)serviceManager.lookup( PropertyStore.ROLE
);
  -
           //Add system properties
           addToStore( store, System.getProperties() );
   
           //Add runtime info
           store.setProperty( "myrmidon.container.description", Constants.BUILD_DESCRIPTION
);
           store.setProperty( "myrmidon.home", m_context.get( "myrmidon.home" ) );
  -
  -        return store;
       }
   
       /**
  
  
  
  1.21      +3 -2      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutionFrame.java
  
  Index: DefaultExecutionFrame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/executor/DefaultExecutionFrame.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DefaultExecutionFrame.java	21 Jun 2002 03:01:09 -0000	1.20
  +++ DefaultExecutionFrame.java	21 Jun 2002 08:05:34 -0000	1.21
  @@ -14,6 +14,7 @@
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.components.workspace.DefaultTaskContext;
  +import org.apache.myrmidon.components.role.DefaultRoleManager;
   import org.apache.myrmidon.interfaces.event.TaskEventManager;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.property.PropertyStore;
  @@ -134,7 +135,7 @@
               final PropertyStore ps = basePS.createChildStore();
   
               final RoleManager baseRM = (RoleManager)lookup( RoleManager.ROLE );
  -            final RoleManager rm = baseRM;
  +            final RoleManager rm = new DefaultRoleManager( baseRM );
   
               final TypeManager baseTM = (TypeManager)lookup( TypeManager.ROLE );
               final TypeManager tm = baseTM.getChildTypeManager( rm );
  
  
  
  1.29      +4 -28     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/type/DefaultTypeManager.java
  
  Index: DefaultTypeManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/type/DefaultTypeManager.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- DefaultTypeManager.java	21 Jun 2002 02:59:52 -0000	1.28
  +++ DefaultTypeManager.java	21 Jun 2002 08:05:35 -0000	1.29
  @@ -10,9 +10,6 @@
   import java.util.HashMap;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -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.role.RoleInfo;
   import org.apache.myrmidon.interfaces.role.RoleManager;
   import org.apache.myrmidon.interfaces.type.TypeException;
  @@ -28,7 +25,7 @@
    * @version $Revision$ $Date$
    */
   public class DefaultTypeManager
  -    implements TypeRegistry, TypeManager, Serviceable
  +    implements TypeRegistry, TypeManager
   {
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultTypeManager.class );
  @@ -41,36 +38,15 @@
   
       private RoleManager m_roleManager;
   
  -    public DefaultTypeManager()
  -    {
  -        this( null, null );
  -    }
  -
       /**
        * Create a chained DefaultTypeManager which wraps a parent TypeManager.
        * @param parent The parent TypeManager - unknown types are delegated to the parent.
        */
  -    private DefaultTypeManager( final DefaultTypeManager parent,
  -                                final RoleManager roleManager )
  +    public DefaultTypeManager( final DefaultTypeManager parent,
  +                               final RoleManager roleManager )
       {
           m_parent = parent;
           m_roleManager = roleManager;
  -    }
  -
  -    /**
  -     * @see Serviceable#service( ServiceManager )
  -     */
  -    public void service( final ServiceManager serviceManager )
  -        throws ServiceException
  -    {
  -        // TODO - probably should always use the role manager from the current
  -        // scope, rather than the parent's.  Need to fix createFactory() to
  -        // deal with the fact that the role name might be different in parent.
  -        // Better yet, change lookup from role name to a Class object.
  -        if( m_roleManager == null )
  -        {
  -            m_roleManager = (RoleManager)serviceManager.lookup( RoleManager.ROLE );
  -        }
       }
   
       /**
  
  
  
  1.96      +1 -4      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.95
  retrieving revision 1.96
  diff -u -r1.95 -r1.96
  --- DefaultWorkspace.java	21 Jun 2002 03:01:41 -0000	1.95
  +++ DefaultWorkspace.java	21 Jun 2002 08:05:35 -0000	1.96
  @@ -137,9 +137,6 @@
               final ExecutionFrame childFrame =
                   frame.createPartition( project.getProjectName(), project.getBaseDirectory()
);
   
  -            // TODO - move all this stuff to a customised ServiceManager, and call
  -            // from ExecutionFrame.createPartition( ..., true ).
  -
               // Add child services, for the scoped services.
               final Map services = new HashMap();
               addChildService( Deployer.ROLE, frame, services );
  
  
  
  1.48      +9 -7      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.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- AbstractComponentTest.java	13 Jun 2002 03:04:35 -0000	1.47
  +++ AbstractComponentTest.java	21 Jun 2002 08:05:35 -0000	1.48
  @@ -95,7 +95,14 @@
               m_serviceManager.put( ConverterRegistry.ROLE, component );
               components.add( component );
   
  -            component = createComponent( TypeManager.ROLE, DefaultTypeManager.class );
  +            final RoleManager roleManager =
  +                (RoleManager)createComponent( RoleManager.ROLE, DefaultRoleManager.class
);
  +            component = roleManager;
  +            m_serviceManager.put( RoleManager.ROLE, component );
  +            m_serviceManager.put( RoleRegistry.ROLE, component );
  +            components.add( component );
  +
  +            component = new DefaultTypeManager( null, roleManager );
               m_serviceManager.put( TypeManager.ROLE, component );
               m_serviceManager.put( TypeRegistry.ROLE, component );
               components.add( component );
  @@ -118,11 +125,6 @@
   
               component = createComponent( ExtensionManager.ROLE, DefaultExtensionManager.class
);
               m_serviceManager.put( ExtensionManager.ROLE, component );
  -            components.add( component );
  -
  -            component = createComponent( RoleManager.ROLE, DefaultRoleManager.class );
  -            m_serviceManager.put( RoleManager.ROLE, component );
  -            m_serviceManager.put( RoleRegistry.ROLE, component );
               components.add( component );
   
               component = createComponent( PropertyResolver.ROLE, DefaultPropertyResolver.class
);
  
  
  
  1.8       +5 -3      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/type/test/DefaultTypeManagerTestCase.java
  
  Index: DefaultTypeManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/type/test/DefaultTypeManagerTestCase.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultTypeManagerTestCase.java	21 Jun 2002 02:59:52 -0000	1.7
  +++ DefaultTypeManagerTestCase.java	21 Jun 2002 08:05:35 -0000	1.8
  @@ -52,8 +52,10 @@
       {
           super.setUp();
           registerRole( new RoleInfo( TestRole.ROLE, TestRole.class ) );
  -        m_typeManager = new DefaultTypeManager();
  -        m_typeManager.service( getServiceManager() );
  +
  +        final RoleManager roleManager =
  +            (RoleManager)getServiceManager().lookup( RoleManager.ROLE );
  +        m_typeManager = new DefaultTypeManager( null, roleManager );
       }
   
       public void testRegister() throws Exception
  
  
  

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