ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/listener ProjectListenerDeployer.java
Date Mon, 24 Jun 2002 01:50:03 GMT
adammurdoch    2002/06/23 18:50:03

  Modified:    container/src/conf ant-services.xml
               container/src/java/org/apache/myrmidon/components/deployer
                        CompoundTypeDeployer.java
                        ConverterTypeDeployer.java DefaultDeployer.java
                        DefaultTypeLibraryDeployer.java
               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/workspace
                        DefaultWorkspace.java
               container/src/java/org/apache/myrmidon/interfaces/deployer
                        DefaultTypeDeployer.java Deployer.java
                        TypeDeployer.java
               container/src/java/org/apache/myrmidon/interfaces/service
                        ServiceDeployer.java
               container/src/test/org/apache/myrmidon/components/deployer/test
                        DefaultDeployerTestCase.java
               antlib/src/java/org/apache/antlib/runtime
                        AbstractTypeLibTask.java ConverterDef.java
                        TypeDef.java
               framework/src/java/org/apache/myrmidon/framework
                        DataTypeDeployer.java
               framework/src/java/org/apache/myrmidon/framework/listener
                        ProjectListenerDeployer.java
  Log:
  Turned Deployer into a non-scoped service:
  - Added TaskContext parameter to all Deployer methods.
  - Added TaskContext parameter to TypeDeployer method.
  - TypeDeployers are no longer service()ed.
  - Removed special treatment for deployer in DefaultEmbeddor and
    DefaultWorkspace.
  - Added DefaultDeployer to ant-services.xml.
  
  Revision  Changes    Path
  1.4       +3 -0      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ant-services.xml	21 Jun 2002 08:05:34 -0000	1.3
  +++ ant-services.xml	24 Jun 2002 01:50:01 -0000	1.4
  @@ -1,4 +1,7 @@
   <services>
  +    <service classname="org.apache.myrmidon.components.deployer.DefaultDeployer">
  +        <role name="org.apache.myrmidon.interfaces.deployer.Deployer"/>
  +    </service>
       <service classname="org.apache.myrmidon.components.extensions.DefaultExtensionManager">
           <role name="org.apache.myrmidon.interfaces.extensions.ExtensionManager"/>
       </service>
  
  
  
  1.10      +7 -12     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/CompoundTypeDeployer.java
  
  Index: CompoundTypeDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/CompoundTypeDeployer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- CompoundTypeDeployer.java	23 Jun 2002 07:43:25 -0000	1.9
  +++ CompoundTypeDeployer.java	24 Jun 2002 01:50:01 -0000	1.10
  @@ -11,9 +11,8 @@
   import java.util.Map;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.interfaces.ComponentException;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
   import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
  @@ -34,17 +33,14 @@
   
       private final Map m_deployers = new HashMap();
       private final TypeDeployer m_defaultDeployer;
  -    private final ServiceManager m_serviceManager;
       private final RoleManager m_roleManager;
   
       public CompoundTypeDeployer( final TypeDeployer defaultDeployer,
  -                                 final ServiceManager serviceManager )
  +                                 final RoleManager roleManager )
           throws ServiceException
       {
           m_defaultDeployer = defaultDeployer;
  -        ContainerUtil.service( m_defaultDeployer, serviceManager );
  -        m_serviceManager = serviceManager;
  -        m_roleManager = (RoleManager)serviceManager.lookup( RoleManager.ROLE );
  +        m_roleManager = roleManager;
       }
   
       /**
  @@ -53,7 +49,6 @@
       public void addDeployer( final String role, final TypeDeployer deployer )
           throws ServiceException
       {
  -        ContainerUtil.service( deployer, m_serviceManager );
           m_deployers.put( role, deployer );
       }
   
  @@ -61,7 +56,8 @@
        * Deploys a type.
        */
       public void deployType( final String namespace,
  -                            final TypeDefinition typeDefinition )
  +                            final TypeDefinition typeDefinition,
  +                            final TaskContext context )
           throws Exception
       {
           // Validate the type definition
  @@ -81,7 +77,7 @@
           // Use the deployer for the type's role, if any.  Otherwise use the
           // default deployer
           final TypeDeployer deployer = findDeployer( roleName );
  -        deployer.deployType( namespace, typeDefinition );
  +        deployer.deployType( namespace, typeDefinition, context );
       }
   
       /**
  @@ -111,7 +107,6 @@
                       final ClassLoader classLoader = role.getImplementationClass().getClassLoader();
                       final Class typeDeployerClass = classLoader.loadClass( typeDeployerClassName
);
                       deployer = (TypeDeployer)typeDeployerClass.newInstance();
  -                    ContainerUtil.service( deployer, m_serviceManager );
                   }
                   catch( final Exception e )
                   {
  
  
  
  1.9       +8 -17     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/ConverterTypeDeployer.java
  
  Index: ConverterTypeDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/ConverterTypeDeployer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ConverterTypeDeployer.java	9 Jun 2002 13:25:40 -0000	1.8
  +++ ConverterTypeDeployer.java	24 Jun 2002 01:50:01 -0000	1.9
  @@ -9,15 +9,13 @@
   
   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.excalibur.converter.ConverterFactory;
  +import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.interfaces.converter.ConverterRegistry;
   import org.apache.myrmidon.interfaces.deployer.DefaultTypeDeployer;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
   import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
  -import org.apache.excalibur.converter.ConverterFactory;
   
   /**
    * A type deployer that deploys converters, registering them with the type
  @@ -28,25 +26,17 @@
    */
   class ConverterTypeDeployer
       extends DefaultTypeDeployer
  -    implements TypeDeployer, Serviceable
  +    implements TypeDeployer
   {
       private static final Resources REZ =
           ResourceManager.getPackageResources( ConverterTypeDeployer.class );
   
  -    private ConverterRegistry m_converterRegistry;
  -
  -    public void service( final ServiceManager serviceManager )
  -        throws ServiceException
  -    {
  -        super.service( serviceManager );
  -        m_converterRegistry = (ConverterRegistry)serviceManager.lookup( ConverterRegistry.ROLE
);
  -    }
  -
       /**
        * Deploys a type.
        */
       public void deployType( final String namespace,
  -                            final TypeDefinition typeDefinition )
  +                            final TypeDefinition typeDefinition,
  +                            final TaskContext context )
           throws Exception
       {
           // Do some validation
  @@ -67,6 +57,7 @@
           final String name = typeDefinition.getName();
           final TypeFactory factory = typeDefinition.getFactory();
           final ConverterFactory converterFactory = new TypeToConverterFactoryAdaptor( name,
factory );
  -        m_converterRegistry.registerConverter( source, destination, converterFactory );
  +        final ConverterRegistry converterRegistry = (ConverterRegistry)context.getService(
ConverterRegistry.class );
  +        converterRegistry.registerConverter( source, destination, converterFactory );
       }
   }
  
  
  
  1.50      +18 -23    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultDeployer.java
  
  Index: DefaultDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultDeployer.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- DefaultDeployer.java	24 Jun 2002 00:53:43 -0000	1.49
  +++ DefaultDeployer.java	24 Jun 2002 01:50:01 -0000	1.50
  @@ -14,13 +14,14 @@
   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.api.TaskContext;
   import org.apache.myrmidon.interfaces.deployer.DefaultTypeDeployer;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.deployer.DeploymentException;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
   import org.apache.myrmidon.interfaces.library.Library;
  +import org.apache.myrmidon.interfaces.role.RoleManager;
   import org.apache.myrmidon.interfaces.role.RoleRegistry;
  -import org.apache.myrmidon.interfaces.service.ScopedService;
   
   /**
    * This class deploys roles, types and services from a typelib.
  @@ -31,7 +32,7 @@
    */
   public class DefaultDeployer
       extends AbstractLogEnabled
  -    implements Deployer, ScopedService, Serviceable
  +    implements Deployer, Serviceable
   {
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultDeployer.class );
  @@ -50,28 +51,20 @@
           throws ServiceException
       {
           m_roleRegistry = (RoleRegistry)serviceManager.lookup( RoleRegistry.ROLE );
  +        final RoleManager roleManager = (RoleManager)serviceManager.lookup( RoleManager.ROLE
);
   
           // Assemble the type deployer
           final DefaultTypeDeployer defaultDeployer = new DefaultTypeDeployer();
  -        m_typeDeployer = new CompoundTypeDeployer( defaultDeployer, serviceManager );
  +        m_typeDeployer = new CompoundTypeDeployer( defaultDeployer, roleManager );
           final ConverterTypeDeployer converterDeployer = new ConverterTypeDeployer();
           m_typeDeployer.addDeployer( "converter", converterDeployer );
       }
   
       /**
  -     * Creates a child deployer.
  -     */
  -    public Object createChildService() throws Exception
  -    {
  -        return new DefaultDeployer();
  -    }
  -
  -    /**
        * Returns the deployer for a library, creating the deployer if
        * necessary.
        */
  -    private DefaultTypeLibraryDeployer createDeployer( final Library library,
  -                                                       final String namespace )
  +    private DefaultTypeLibraryDeployer createDeployer( final Library library )
           throws DeploymentException
       {
           try
  @@ -79,7 +72,6 @@
               final DefaultTypeLibraryDeployer deployment =
                   new DefaultTypeLibraryDeployer( m_roleRegistry,
                                                   m_typeDeployer,
  -                                                namespace,
                                                   library.getClassLoader() );
               ContainerUtil.enableLogging( deployment, getLogger() );
               deployment.loadDescriptors( library.getClassPath() );
  @@ -97,11 +89,12 @@
        * Deploys all the types from a library.
        */
       public void deployTypes( final Library library,
  -                             final String namespace )
  +                             final String namespace,
  +                             final TaskContext context )
           throws DeploymentException
       {
  -        final DefaultTypeLibraryDeployer deployer = createDeployer( library, namespace
);
  -        deployer.deployAll();
  +        final DefaultTypeLibraryDeployer deployer = createDeployer( library );
  +        deployer.deployAll( namespace, context );
       }
   
       /**
  @@ -111,23 +104,25 @@
       public void deployType( final Library library,
                               final String namespace,
                               final String role,
  -                            final String typeName )
  +                            final String typeName,
  +                            final TaskContext context )
           throws DeploymentException
       {
  -        final DefaultTypeLibraryDeployer deployer = createDeployer( library, namespace
);
  -        deployer.deployType( role, typeName );
  +        final DefaultTypeLibraryDeployer deployer = createDeployer( library );
  +        deployer.deployType( namespace, role, typeName, context );
       }
   
       /**
        * Deploys a single type from the type library.
        */
       public void deployType( final String namespace,
  -                            final TypeDefinition typeDef )
  +                            final TypeDefinition typeDef,
  +                            final TaskContext context )
           throws DeploymentException
       {
           try
           {
  -            m_typeDeployer.deployType( namespace, typeDef );
  +            m_typeDeployer.deployType( namespace, typeDef, context );
           }
           catch( Exception e )
           {
  
  
  
  1.13      +17 -12    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultTypeLibraryDeployer.java
  
  Index: DefaultTypeLibraryDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultTypeLibraryDeployer.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultTypeLibraryDeployer.java	24 Jun 2002 00:53:43 -0000	1.12
  +++ DefaultTypeLibraryDeployer.java	24 Jun 2002 01:50:01 -0000	1.13
  @@ -24,6 +24,7 @@
   import org.apache.myrmidon.interfaces.role.RoleInfo;
   import org.apache.myrmidon.interfaces.role.RoleRegistry;
   import org.apache.myrmidon.interfaces.type.ClassLoaderTypeFactory;
  +import org.apache.myrmidon.api.TaskContext;
   import org.xml.sax.XMLReader;
   
   /**
  @@ -45,7 +46,6 @@
       private static final String ROLE_DESCRIPTOR_NAME = "META-INF/ant-roles.xml";
   
       private final TypeDeployer m_typeDeployer;
  -    private final String m_namespace;
       private final ClassLoader m_classLoader;
       private TypeDescriptor[] m_descriptors;
   
  @@ -59,12 +59,10 @@
   
       public DefaultTypeLibraryDeployer( final RoleRegistry roleRegistry,
                                          final TypeDeployer typeDeployer,
  -                                       final String namespace,
                                          final ClassLoader classLoader )
       {
           m_roleRegistry = roleRegistry;
           m_typeDeployer = typeDeployer;
  -        m_namespace = namespace;
           m_classLoader = classLoader;
       }
   
  @@ -137,21 +135,24 @@
       /**
        * Deploys everything in the type library.
        */
  -    public void deployAll()
  +    public void deployAll( final String namespace, final TaskContext context )
           throws DeploymentException
       {
           // Deploy types
           for( int i = 0; i < m_descriptors.length; i++ )
           {
               TypeDescriptor descriptor = m_descriptors[ i ];
  -            deployTypes( descriptor );
  +            deployTypes( namespace, descriptor, context );
           }
       }
   
       /**
        * Deploys a single type in the type library.
        */
  -    public void deployType( final String roleName, final String typeName )
  +    public void deployType( final String namespace,
  +                            final String roleName,
  +                            final String typeName,
  +                            final TaskContext context )
           throws DeploymentException
       {
           try
  @@ -170,7 +171,7 @@
                           // Found the definition - deploy it.  Note that we
                           // keep looking for matching types, and let the deployer
                           // deal with duplicates
  -                        doDeployType( definition );
  +                        doDeployType( namespace, definition, context );
                       }
                   }
               }
  @@ -185,10 +186,12 @@
       /**
        * Deploys a type.
        */
  -    private void doDeployType( final TypeDefinition typeDef )
  +    private void doDeployType( final String namespace,
  +                               final TypeDefinition typeDef,
  +                               final TaskContext context )
           throws Exception
       {
  -        m_typeDeployer.deployType( m_namespace, typeDef );
  +        m_typeDeployer.deployType( namespace, typeDef, context );
   
           if( getLogger().isDebugEnabled() )
           {
  @@ -312,7 +315,9 @@
       /**
        * Deploys all types from a typelib descriptor.
        */
  -    private void deployTypes( final TypeDescriptor descriptor )
  +    private void deployTypes( final String namespace,
  +                              final TypeDescriptor descriptor,
  +                              final TaskContext context )
           throws DeploymentException
       {
           try
  @@ -329,7 +334,7 @@
               for( int i = 0; i < definitions.length; i++ )
               {
                   final TypeDefinition definition = definitions[ i ];
  -                doDeployType( definition );
  +                doDeployType( namespace, definition, context );
               }
           }
           catch( final Exception e )
  
  
  
  1.105     +5 -11     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.104
  retrieving revision 1.105
  diff -u -r1.104 -r1.105
  --- DefaultEmbeddor.java	24 Jun 2002 00:53:44 -0000	1.104
  +++ DefaultEmbeddor.java	24 Jun 2002 01:50:01 -0000	1.105
  @@ -188,11 +188,8 @@
           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 );
  +        // Add this embeddor
  +        m_serviceManager.registerService( new String[]{Embeddor.ROLE}, this );
   
           // locate the components we need
           m_deployer = (Deployer)m_serviceManager.lookup( Deployer.ROLE );
  @@ -213,7 +210,7 @@
           final ClassLoader containerClassLoader = getClass().getClassLoader();
           final Library containerLib =
               m_libraryManager.createLibrary( containerClassLoader );
  -        m_deployer.deployTypes( containerLib, CONTAINER_TYPE_NAMESPACE );
  +        m_deployer.deployTypes( containerLib, CONTAINER_TYPE_NAMESPACE, m_rootContext );
   
           // Deploy all core type libraries in the lib directory
           final Library[] coreLibs = m_libraryManager.getCoreLibraries();
  @@ -239,7 +236,7 @@
                   getLogger().debug( message );
               }
   
  -            m_deployer.deployTypes( library, library.getName() );
  +            m_deployer.deployTypes( library, library.getName(), m_rootContext );
           }
       }
   
  @@ -300,9 +297,6 @@
               final Configuration serviceDef = serviceDefs[ i ];
               registerService( registry, serviceDef );
           }
  -
  -        // Add this embeddor
  -        registry.registerService( new String[]{Embeddor.ROLE}, this );
       }
   
       /**
  
  
  
  1.22      +2 -1      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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DefaultExecutionFrame.java	21 Jun 2002 08:05:34 -0000	1.21
  +++ DefaultExecutionFrame.java	24 Jun 2002 01:50:01 -0000	1.22
  @@ -129,6 +129,7 @@
                                              final File baseDirectory )
       {
           //What an UGLY Hack!!!
  +        // TODO - we never dispose of these services.  That's bad
           try
           {
               final PropertyStore basePS = (PropertyStore)lookup( PropertyStore.ROLE );
  
  
  
  1.99      +2 -67     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.98
  retrieving revision 1.99
  diff -u -r1.98 -r1.99
  --- DefaultWorkspace.java	23 Jun 2002 10:52:27 -0000	1.98
  +++ DefaultWorkspace.java	24 Jun 2002 01:50:01 -0000	1.99
  @@ -7,19 +7,14 @@
    */
   package org.apache.myrmidon.components.workspace;
   
  -import java.util.Collection;
   import java.util.HashMap;
  -import java.util.Iterator;
   import java.util.Map;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.service.ServiceManager;
  -import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.api.TaskContext;
  +import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.api.metadata.ModelElement;
  -import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.executor.Executor;
  @@ -27,7 +22,6 @@
   import org.apache.myrmidon.interfaces.model.ProjectRef;
   import org.apache.myrmidon.interfaces.model.Target;
   import org.apache.myrmidon.interfaces.property.PropertyStore;
  -import org.apache.myrmidon.interfaces.service.ScopedService;
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
   
  @@ -142,17 +136,8 @@
           {
               final ExecutionFrame childFrame =
                   frame.createPartition( project.getProjectName(), project.getBaseDirectory()
);
  -
  -            // Add child services, for the scoped services.
  -            final Map services = new HashMap();
  -            addChildService( Deployer.ROLE, frame, services );
  -
               frame.registerService( Workspace.ROLE, this );
   
  -            setupServices( services.values(), childFrame.getServiceManager() );
  -
  -            // TODO - we never dispose of these services.  That's bad
  -
               final PropertyStore propertyStore =
                   (PropertyStore)childFrame.lookup( PropertyStore.ROLE );
               propertyStore.setProperty( ProjectDescriptor.KEY,
  @@ -170,56 +155,6 @@
           catch( final Exception e )
           {
               throw new TaskException( e.getMessage(), e );
  -        }
  -    }
  -
  -    /**
  -     * Initialises a set of services
  -     * @param services The services
  -     */
  -    private void setupServices( final Collection services,
  -                                final ServiceManager serviceManager )
  -        throws Exception
  -    {
  -        for( Iterator iterator = services.iterator(); iterator.hasNext(); )
  -        {
  -            final Object object = iterator.next();
  -            ContainerUtil.enableLogging( object, getLogger() );
  -            // TODO - need to contextualise services
  -            //ContainerUtil.contextualize( object, m_context );
  -            ContainerUtil.service( object, serviceManager );
  -            ContainerUtil.initialize( object );
  -        }
  -    }
  -
  -    /**
  -     * Creates a child service for a service, if the specified service is a
  -     * scoped service.
  -     * @param role The service to create a child for.
  -     * @param scopedServices A map tracking the services for which a child
  -     *        service has already been created.  This is to deal with service
  -     *        object which provide more than one service.
  -     */
  -    private void addChildService( final String role,
  -                                  final ExecutionFrame frame,
  -                                  final Map scopedServices )
  -        throws Exception
  -    {
  -        // Lookup the service, and skip it if it is not a scoped service
  -        final Object service = frame.lookup( role );
  -        if( !( service instanceof ScopedService ) )
  -        {
  -            return;
  -        }
  -
  -        // Check if a child has already been created for the service, and
  -        // use that instead of creating a new one.  Otherwise create the child.
  -        Object childService = scopedServices.get( service );
  -        if( childService == null )
  -        {
  -            childService = ( (ScopedService)service ).createChildService();
  -            scopedServices.put( service, childService );
  -            frame.registerService( role, childService );
           }
       }
   
  
  
  
  1.6       +14 -33    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/DefaultTypeDeployer.java
  
  Index: DefaultTypeDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/DefaultTypeDeployer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultTypeDeployer.java	9 Jun 2002 13:25:40 -0000	1.5
  +++ DefaultTypeDeployer.java	24 Jun 2002 01:50:01 -0000	1.6
  @@ -7,13 +7,11 @@
    */
   package org.apache.myrmidon.interfaces.deployer;
   
  -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.api.TaskContext;
  +import org.apache.myrmidon.interfaces.role.RoleInfo;
  +import org.apache.myrmidon.interfaces.role.RoleManager;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeRegistry;
  -import org.apache.myrmidon.interfaces.role.RoleManager;
  -import org.apache.myrmidon.interfaces.role.RoleInfo;
   
   /**
    * A general-purpose type deployer, which registers the type with the type
  @@ -23,44 +21,27 @@
    * @version $Revision$ $Date$
    */
   public class DefaultTypeDeployer
  -    implements TypeDeployer, Serviceable
  +    implements TypeDeployer
   {
  -    private TypeRegistry m_typeRegistry;
  -    private RoleManager m_roleManager;
  -
  -    protected TypeRegistry getTypeRegistry()
  -    {
  -        return m_typeRegistry;
  -    }
  -
  -    public void service( final ServiceManager serviceManager )
  -        throws ServiceException
  -    {
  -        m_typeRegistry = (TypeRegistry)serviceManager.lookup( TypeRegistry.ROLE );
  -        m_roleManager = (RoleManager)serviceManager.lookup( RoleManager.ROLE );
  -    }
  -
       /**
        * Deploys a type.
        */
       public void deployType( final String namespace,
  -                            final TypeDefinition typeDefinition )
  +                            final TypeDefinition typeDefinition,
  +                            final TaskContext context )
           throws Exception
       {
           final String roleName = typeDefinition.getRole();
           final String typeName = typeDefinition.getName();
           final TypeFactory typeFactory = typeDefinition.getFactory();
   
  -        final String classname = getInterfaceName( roleName );
  -        m_typeRegistry.registerType( classname,
  -                                     namespace,
  -                                     typeName,
  -                                     typeFactory );
  -    }
  +        final RoleManager roleManager = (RoleManager)context.getService( RoleManager.class
);
  +        final RoleInfo role = roleManager.getRoleByShortName( roleName );
   
  -    protected String getInterfaceName( final String shortName )
  -    {
  -        final RoleInfo role = m_roleManager.getRoleByShortName( shortName );
  -        return role.getInterfaceName();
  +        final TypeRegistry typeRegistry = (TypeRegistry)context.getService( TypeRegistry.class
);
  +        typeRegistry.registerType( role.getInterfaceName(),
  +                                   namespace,
  +                                   typeName,
  +                                   typeFactory );
       }
   }
  
  
  
  1.16      +19 -10    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/Deployer.java
  
  Index: Deployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/Deployer.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Deployer.java	24 Jun 2002 00:53:44 -0000	1.15
  +++ Deployer.java	24 Jun 2002 01:50:02 -0000	1.16
  @@ -8,6 +8,7 @@
   package org.apache.myrmidon.interfaces.deployer;
   
   import org.apache.myrmidon.interfaces.library.Library;
  +import org.apache.myrmidon.api.TaskContext;
   
   /**
    * This class deploys type libraries into a registry.
  @@ -23,37 +24,45 @@
   
       /**
        * Deploys all the types from a library.
  +     *
        * @param library The library to deploy from.
        * @param namespace The namespace to deploy into.  Use null to deploy into
        *        the default namespace.
  +     * @param context The context to deploy into.
        */
  -    void deployTypes( Library library, String namespace )
  +    void deployTypes( Library library, String namespace, TaskContext context )
           throws DeploymentException;
   
       /**
        * Deploys a single type from a library.
  +     *
        * @param library The library to deploy from.
        * @param namespace The namespace to deploy into.  Use null to deploy into
        *        the default namespace.
        * @param role The role name.
        * @param typeName The type name.
  -     *
  +     * @param context The context to deploy into.
        */
  -    void deployType( Library library, String namespace, String role, String typeName )
  +    void deployType( Library library,
  +                     String namespace,
  +                     String role,
  +                     String typeName,
  +                     TaskContext context )
           throws DeploymentException;
   
       /**
        * Deploys a single type.
        *
  -     * @param namespace
  -     *      The namespace to deploy the type into.  Use null to deploy into
  -     *      the default namespace.
  -     * @param typeDef
  -     *      The type definition.
  +     * @param namespace The namespace to deploy the type into.  Use null to
  +     *        deploy into the default namespace.
  +     * @param typeDef The type definition.
  +     * @param context The context to deploy into.
        *
        * @throws DeploymentException
        *      If the type cannot be deployed.
        */
  -    void deployType( String namespace, TypeDefinition typeDef )
  +    void deployType( String namespace,
  +                     TypeDefinition typeDef,
  +                     TaskContext context )
           throws DeploymentException;
   }
  
  
  
  1.10      +6 -3      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/TypeDeployer.java
  
  Index: TypeDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/TypeDeployer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TypeDeployer.java	22 May 2002 07:36:22 -0000	1.9
  +++ TypeDeployer.java	24 Jun 2002 01:50:02 -0000	1.10
  @@ -7,6 +7,8 @@
    */
   package org.apache.myrmidon.interfaces.deployer;
   
  +import org.apache.myrmidon.api.TaskContext;
  +
   /**
    * Deploys the types of a particular role.
    *
  @@ -20,9 +22,10 @@
        *
        * @param namespace The namespace to deploy the types under.
        * @param typeDefinition The type to deploy.
  -     * @throws java.lang.Exception On error.
  +     * @param context The context to deploy the types into.
        */
       void deployType( String namespace,
  -                     TypeDefinition typeDefinition )
  +                     TypeDefinition typeDefinition,
  +                     TaskContext context )
           throws Exception;
   }
  
  
  
  1.3       +11 -22    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/service/ServiceDeployer.java
  
  Index: ServiceDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/service/ServiceDeployer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServiceDeployer.java	15 Jun 2002 08:00:21 -0000	1.2
  +++ ServiceDeployer.java	24 Jun 2002 01:50:02 -0000	1.3
  @@ -7,15 +7,11 @@
    */
   package org.apache.myrmidon.interfaces.service;
   
  -import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
  +import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  -import org.apache.myrmidon.interfaces.service.ServiceRegistry;
  -import org.apache.myrmidon.interfaces.service.ServiceFactory;
  -import org.apache.myrmidon.interfaces.role.RoleManager;
  +import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
   import org.apache.myrmidon.interfaces.role.RoleInfo;
  -import org.apache.avalon.framework.service.Serviceable;
  -import org.apache.avalon.framework.service.ServiceManager;
  -import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.myrmidon.interfaces.role.RoleManager;
   
   /**
    * Deploys services.
  @@ -26,30 +22,23 @@
    * @todo Handle services that provide more than one role.
    */
   public class ServiceDeployer
  -    implements TypeDeployer, Serviceable
  +    implements TypeDeployer
   {
  -    private ServiceRegistry m_serviceRegistry;
  -    private RoleManager m_roleManager;
  -
  -    public void service( final ServiceManager serviceManager )
  -        throws ServiceException
  -    {
  -        m_serviceRegistry = (ServiceRegistry)serviceManager.lookup( ServiceRegistry.ROLE
);
  -        m_roleManager = (RoleManager)serviceManager.lookup( RoleManager.ROLE );
  -    }
  -
       /**
        * Deploys a type.
        */
       public void deployType( final String namespace,
  -                            final TypeDefinition typeDefinition )
  +                            final TypeDefinition typeDefinition,
  +                            final TaskContext context )
           throws Exception
       {
           // Create and register the service factory
           final String name = typeDefinition.getName();
  -        final RoleInfo roleInfo = m_roleManager.getRoleByShortName( name );
  +        final RoleManager roleManager = (RoleManager)context.getService( RoleManager.class
);
  +        final RoleInfo roleInfo = roleManager.getRoleByShortName( name );
           final ServiceFactory factory = (ServiceFactory)typeDefinition.getFactory().create(
name );
           final ServiceDescriptor descriptor = new ServiceDescriptor( roleInfo.getInterfaceName(),
factory );
  -        m_serviceRegistry.registerService( descriptor );
  +        final ServiceRegistry serviceRegistry = (ServiceRegistry)context.getService( ServiceRegistry.class
);
  +        serviceRegistry.registerService( descriptor );
       }
   }
  
  
  
  1.17      +3 -3      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/deployer/test/DefaultDeployerTestCase.java
  
  Index: DefaultDeployerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/deployer/test/DefaultDeployerTestCase.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DefaultDeployerTestCase.java	24 Jun 2002 00:53:44 -0000	1.16
  +++ DefaultDeployerTestCase.java	24 Jun 2002 01:50:03 -0000	1.17
  @@ -102,7 +102,7 @@
           assertTypesNotRegistered();
   
           // Deploy the type
  -        m_deployer.deployType( TEST_NAMESPACE, typeDef );
  +        m_deployer.deployType( TEST_NAMESPACE, typeDef, createContext() );
   
           // Check the type has been registered
           assertTypeRegistered( TestDataType.ROLE, typeName, TestType1.class );
  @@ -135,7 +135,7 @@
           assertTypesNotRegistered();
   
           // Deploy the type
  -        m_deployer.deployType( TEST_NAMESPACE, typeDef );
  +        m_deployer.deployType( TEST_NAMESPACE, typeDef, createContext() );
   
           // Try to convert from string to test type
           final Object result = m_converter.convert( TestType1.class, "some-string", null
);
  @@ -154,7 +154,7 @@
           assertTypesNotRegistered();
   
           // Deploy all the types from the descriptor
  -        m_deployer.deployTypes( testLib, TEST_NAMESPACE );
  +        m_deployer.deployTypes( testLib, TEST_NAMESPACE, createContext() );
   
           // Make sure the test types have been deployed
           assertTypesRegistered();
  
  
  
  1.3       +3 -3      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/AbstractTypeLibTask.java
  
  Index: AbstractTypeLibTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/AbstractTypeLibTask.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractTypeLibTask.java	24 Jun 2002 00:53:43 -0000	1.2
  +++ AbstractTypeLibTask.java	24 Jun 2002 01:50:03 -0000	1.3
  @@ -99,12 +99,12 @@
               if( null == m_role )
               {
                   // Deploy everything in the typelib
  -                deployer.deployTypes( library, m_namespace );
  +                deployer.deployTypes( library, m_namespace, getContext() );
               }
               else
               {
                   // Deploy the specified type
  -                deployer.deployType( library, m_namespace, m_role, m_name );
  +                deployer.deployType( library, m_namespace, m_role, m_name, getContext()
);
               }
           }
           catch( final Exception e )
  
  
  
  1.8       +1 -1      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/ConverterDef.java
  
  Index: ConverterDef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/ConverterDef.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ConverterDef.java	9 Jun 2002 13:15:06 -0000	1.7
  +++ ConverterDef.java	24 Jun 2002 01:50:03 -0000	1.8
  @@ -61,6 +61,6 @@
               new TypeDefinition( classname, shortName, typeFactory, attrs );
   
           final Deployer deployer = (Deployer)getService( Deployer.class );
  -        deployer.deployType( null, typeDef );
  +        deployer.deployType( null, typeDef, getContext() );
       }
   }
  
  
  
  1.6       +1 -1      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeDef.java
  
  Index: TypeDef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/TypeDef.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TypeDef.java	23 May 2002 09:36:36 -0000	1.5
  +++ TypeDef.java	24 Jun 2002 01:50:03 -0000	1.6
  @@ -60,6 +60,6 @@
   
           final Deployer deployer = (Deployer)getService( Deployer.class );
           final TypeDefinition typeDef = new TypeDefinition( m_name, m_role, typeFactory
);
  -        deployer.deployType( m_namespace, typeDef );
  +        deployer.deployType( m_namespace, typeDef, getContext() );
       }
   }
  
  
  
  1.6       +10 -7     jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/DataTypeDeployer.java
  
  Index: DataTypeDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/DataTypeDeployer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DataTypeDeployer.java	27 May 2002 08:30:30 -0000	1.5
  +++ DataTypeDeployer.java	24 Jun 2002 01:50:03 -0000	1.6
  @@ -8,11 +8,13 @@
   package org.apache.myrmidon.framework;
   
   import org.apache.myrmidon.api.Task;
  +import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.interfaces.deployer.DefaultTypeDeployer;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
   import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
   import org.apache.myrmidon.interfaces.type.AdaptingTypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
  +import org.apache.myrmidon.interfaces.type.TypeRegistry;
   
   /**
    * A deployer for data-types.  Registers the type, and an instantiating
  @@ -25,22 +27,23 @@
       extends DefaultTypeDeployer
       implements TypeDeployer
   {
  -    private AdaptingTypeFactory m_factory = new AdaptingTypeFactory( TypeInstanceTask.class
);
  -
       /**
        * Deploys a type.
        */
       public void deployType( final String namespace,
  -                            final TypeDefinition typeDefinition )
  +                            final TypeDefinition typeDefinition,
  +                            final TaskContext context )
           throws Exception
       {
           // Register the type itself
  -        super.deployType( namespace, typeDefinition );
  +        super.deployType( namespace, typeDefinition, context );
   
           // Register the instantiating task
           final String name = typeDefinition.getName();
           final TypeFactory typeFactory = typeDefinition.getFactory();
  -        m_factory.addMapping( name, typeFactory );
  -        getTypeRegistry().registerType( Task.ROLE, namespace, name, m_factory );
  +        final AdaptingTypeFactory adaptorFactory = new AdaptingTypeFactory( TypeInstanceTask.class
);
  +        adaptorFactory.addMapping( name, typeFactory );
  +        final TypeRegistry typeRegistry = (TypeRegistry)context.getService( TypeRegistry.class
);
  +        typeRegistry.registerType( Task.ROLE, namespace, name, adaptorFactory );
       }
   }
  
  
  
  1.4       +10 -7     jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/listener/ProjectListenerDeployer.java
  
  Index: ProjectListenerDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/listener/ProjectListenerDeployer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProjectListenerDeployer.java	27 May 2002 08:30:30 -0000	1.3
  +++ ProjectListenerDeployer.java	24 Jun 2002 01:50:03 -0000	1.4
  @@ -11,7 +11,9 @@
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
   import org.apache.myrmidon.interfaces.type.AdaptingTypeFactory;
  +import org.apache.myrmidon.interfaces.type.TypeRegistry;
   import org.apache.myrmidon.api.event.TaskListener;
  +import org.apache.myrmidon.api.TaskContext;
   
   /**
    * A deployer for project listeners.  Registers the listener as a
  @@ -23,22 +25,23 @@
   public class ProjectListenerDeployer
       extends DefaultTypeDeployer
   {
  -    private final AdaptingTypeFactory m_factory = new AdaptingTypeFactory( TaskToProjectListenerAdapter.class
);
  -
       /**
        * Deploys a type.
        */
       public void deployType( final String namespace,
  -                            final TypeDefinition typeDefinition )
  +                            final TypeDefinition typeDefinition,
  +                            final TaskContext context )
           throws Exception
       {
           // Register the listener as a ProjectListener
  -        super.deployType( namespace, typeDefinition );
  +        super.deployType( namespace, typeDefinition, context );
   
           // Register the listener as a TaskListener
           final String typeName = typeDefinition.getName();
           final TypeFactory typeFactory = typeDefinition.getFactory();
  -        m_factory.addMapping( typeName, typeFactory );
  -        getTypeRegistry().registerType( TaskListener.ROLE, namespace, typeDefinition.getName(),
m_factory );
  +        final AdaptingTypeFactory adaptorFactory = new AdaptingTypeFactory( TaskToProjectListenerAdapter.class
);
  +        adaptorFactory.addMapping( typeName, typeFactory );
  +        final TypeRegistry typeRegistry = (TypeRegistry)context.getService( TypeRegistry.class
);
  +        typeRegistry.registerType( TaskListener.ROLE, namespace, typeDefinition.getName(),
adaptorFactory );
       }
   }
  
  
  

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