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/container/src/test/org/apache/myrmidon/components/service/test InstantiatingServiceManagerTestCase.java
Date Sat, 15 Jun 2002 08:00:22 GMT
adammurdoch    2002/06/15 01:00:22

  Modified:    container/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java Resources.properties
               container/src/java/org/apache/myrmidon/components/service
                        InstantiatingServiceManager.java
                        Resources.properties
               container/src/java/org/apache/myrmidon/interfaces/service
                        ServiceDeployer.java ServiceRegistry.java
               container/src/test/org/apache/myrmidon/components/service/test
                        InstantiatingServiceManagerTestCase.java
  Log:
  * Changed ServiceRegistry.registerService() to use a ServiceDescriptor, rather
    than rolename + factory.  Allows a service to provide more than one role.
  
  * DefaultEmbeddor now delegates all service lifecycle management to InstantiatingServiceManager.
  
  Revision  Changes    Path
  1.98      +83 -117   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.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- DefaultEmbeddor.java	15 Jun 2002 03:24:16 -0000	1.97
  +++ DefaultEmbeddor.java	15 Jun 2002 08:00:20 -0000	1.98
  @@ -8,12 +8,9 @@
   package org.apache.myrmidon.components.embeddor;
   
   import java.io.File;
  -import java.util.ArrayList;
   import java.util.Arrays;
   import java.util.Iterator;
  -import java.util.List;
   import java.util.Map;
  -import org.apache.excalibur.converter.Converter;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.activity.Disposable;
  @@ -27,12 +24,15 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.service.DefaultServiceManager;
   import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.excalibur.converter.Converter;
   import org.apache.myrmidon.Constants;
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.api.event.TaskListener;
   import org.apache.myrmidon.api.metadata.ModelElement;
  +import org.apache.myrmidon.components.executor.DefaultExecutionFrame;
   import org.apache.myrmidon.components.property.DefaultPropertyStore;
  +import org.apache.myrmidon.components.service.InstantiatingServiceManager;
   import org.apache.myrmidon.components.workspace.DefaultWorkspace;
   import org.apache.myrmidon.interfaces.builder.ModelBuilder;
   import org.apache.myrmidon.interfaces.builder.ProjectBuilder;
  @@ -42,8 +42,6 @@
   import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
   import org.apache.myrmidon.interfaces.event.TaskEventManager;
  -import org.apache.myrmidon.components.executor.DefaultExecutionFrame;
  -import org.apache.myrmidon.components.service.InstantiatingServiceManager;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.executor.Executor;
   import org.apache.myrmidon.interfaces.extensions.ExtensionManager;
  @@ -53,8 +51,13 @@
   import org.apache.myrmidon.interfaces.property.NameValidatorManager;
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
   import org.apache.myrmidon.interfaces.property.PropertyStore;
  +import org.apache.myrmidon.interfaces.role.RoleInfo;
   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;
  @@ -86,8 +89,8 @@
       private LibraryManager m_libraryManager;
       private Configurer m_configurer;
   
  -    private List m_components = new ArrayList();
  -    private InstantiatingServiceManager m_serviceManager = new InstantiatingServiceManager();
  +    private final InstantiatingServiceManager m_serviceManager = new InstantiatingServiceManager();
  +
       private Context m_context;
       private ExecutionFrame m_rootFrame;
       private TaskContext m_rootContext;
  @@ -238,21 +241,11 @@
        */
       public void dispose()
       {
  -        // Dispose any disposable components
  -        for( Iterator iterator = m_components.iterator(); iterator.hasNext(); )
  -        {
  -            Object component = iterator.next();
  -            if( component instanceof Disposable )
  -            {
  -                final Disposable disposable = (Disposable)component;
  -                disposable.dispose();
  -            }
  -        }
  +        // Cleanup all services
  +        m_serviceManager.dispose();
   
           // Ditch everything
  -        m_components = null;
           m_deployer = null;
  -        m_serviceManager = null;
           m_context = null;
       }
   
  @@ -285,123 +278,96 @@
       {
           setupObject( m_serviceManager, m_serviceManager, null );
   
  -        // Create the components
  -        createComponent( ExtensionManager.ROLE,
  -                         ExtensionManager.class,
  +        final ServiceRegistry registry = (ServiceRegistry)m_serviceManager.lookup( ServiceRegistry.ROLE
);
  +
  +        // Create the role manager first.  It is used to validate the rest
  +        // of the services
  +        registerService( registry,
  +                         null, new String[]{RoleManager.ROLE, RoleRegistry.ROLE},
  +                         PREFIX + "role.DefaultRoleManager" );
  +        final RoleRegistry roleRegistry = (RoleRegistry)m_serviceManager.lookup( RoleRegistry.ROLE
);
  +
  +        // Create the other services
  +        registerService( registry,
  +                         roleRegistry,
  +                         new String[]{ExtensionManager.ROLE},
                            PREFIX + "extensions.DefaultExtensionManager" );
  -        final Object converter =
  -            createComponent( Converter.ROLE,
  -                             Converter.class,
  -                             PREFIX + "converter.DefaultMasterConverter" );
  -        m_serviceManager.put( ConverterRegistry.ROLE, converter );
  -        m_serviceManager.put( "converter", converter );
  -        createComponent( Configurer.ROLE,
  -                         Configurer.class,
  -                         PREFIX + "configurer.DefaultConfigurer" );
  -        final Object typeManager =
  -            createComponent( TypeManager.ROLE,
  -                             TypeManager.class,
  -                             PREFIX + "type.DefaultTypeManager" );
  -        m_serviceManager.put( TypeRegistry.ROLE, typeManager );
  -        final Object roleManager =
  -            createComponent( RoleManager.ROLE,
  -                             RoleManager.class,
  -                             PREFIX + "role.DefaultRoleManager" );
  -        m_serviceManager.put( RoleRegistry.ROLE, roleManager );
  -        createComponent( Deployer.ROLE,
  -                         Deployer.class,
  +        registerService( registry,
  +                         roleRegistry,
  +                         new String[]{TypeManager.ROLE, TypeRegistry.ROLE},
  +                         PREFIX + "type.DefaultTypeManager" );
  +        registerService( registry,
  +                         roleRegistry,
  +                         new String[]{Deployer.ROLE},
                            PREFIX + "deployer.DefaultDeployer" );
  -        createComponent( LibraryManager.ROLE,
  -                         LibraryManager.class,
  +        registerService( registry,
  +                         roleRegistry,
  +                         new String[]{LibraryManager.ROLE},
                            PREFIX + "library.DefaultLibraryManager" );
  -        createComponent( Executor.ROLE,
  -                         Executor.class,
  +        registerService( registry,
  +                         roleRegistry,
  +                         new String[]{Executor.ROLE},
                            PREFIX + "executor.DefaultExecutor" );
  -        createComponent( NameValidatorManager.ROLE,
  -                         NameValidatorManager.class,
  +        registerService( registry,
  +                         roleRegistry,
  +                         new String[]{NameValidatorManager.ROLE},
                            PREFIX + "property.DefaultNameValidatorManager" );
  -        createComponent( PropertyResolver.ROLE,
  -                         PropertyResolver.class,
  +        registerService( registry,
  +                         roleRegistry,
  +                         new String[]{TaskEventManager.ROLE},
  +                         PREFIX + "event.DefaultTaskEventManager" );
  +
  +        // Skip validation for the following services, because the (default)
  +        // role manager complains about duplicate role definitions for them.
  +        // TODO - um, validate them
  +        registerService( registry,
  +                         null,
  +                         new String[]{PropertyResolver.ROLE},
                            PREFIX + "property.DefaultPropertyResolver" );
  -        createComponent( ModelBuilder.ROLE,
  -                         ModelBuilder.class,
  +        registerService( registry,
  +                         null,
  +                         new String[]{Configurer.ROLE},
  +                         PREFIX + "configurer.DefaultConfigurer" );
  +        registerService( registry,
  +                         null,
  +                         new String[]{Converter.ROLE, ConverterRegistry.ROLE},
  +                         PREFIX + "converter.DefaultMasterConverter" );
  +        registerService( registry,
  +                         null,
  +                         new String[]{ModelBuilder.ROLE},
                            PREFIX + "builder.DefaultModelBuilder" );
  -        createComponent( TaskEventManager.ROLE,
  -                         TaskEventManager.class,
  -                         PREFIX + "event.DefaultTaskEventManager" );
  -        createComponent( ProjectBuilder.ROLE,
  -                         ProjectBuilder.class,
  +        registerService( registry,
  +                         null,
  +                         new String[]{ProjectBuilder.ROLE},
                            PREFIX + "builder.MasterProjectBuilder" );
   
           m_serviceManager.put( Embeddor.ROLE, this );
  -
  -        // Setup the components
  -        for( Iterator iterator = m_components.iterator(); iterator.hasNext(); )
  -        {
  -            final Object component = iterator.next();
  -            setupObject( component, m_serviceManager, null );
  -        }
       }
   
       /**
  -     * Creates a component.
  +     * Registers a service, and the roles that it provides.
        */
  -    private Object createComponent( final String roleName,
  -                                    final Class roleType,
  -                                    final String defaultImpl )
  +    private void registerService( final ServiceRegistry serviceRegistry,
  +                                  final RoleRegistry roleRegistry,
  +                                  final String[] roles,
  +                                  final String defaultImplClass )
           throws Exception
       {
  -        final Object component = createService( roleType, defaultImpl );
  -        m_serviceManager.put( roleName, component );
  -        m_components.add( component );
  -        return component;
  -    }
  -
  -    /**
  -     * Create a component that implements an interface.
  -     *
  -     * @param roleType the name of interface/type
  -     * @param defaultImpl the classname of the default implementation
  -     * @return the created object
  -     * @throws Exception if an error occurs
  -     */
  -    private Object createService( final Class roleType, final String defaultImpl )
  -        throws Exception
  -    {
  -        // TODO - need to be able to provide different implementations
  -        final String className = defaultImpl;
  -
  -        try
  +        // Register the roles
  +        if( roleRegistry != null )
           {
  -            final Object object = Class.forName( className ).newInstance();
  -
  -            if( !roleType.isInstance( object ) )
  +            for( int i = 0; i < roles.length; i++ )
               {
  -                final String message = REZ.getString( "bad-type.error",
  -                                                      className, roleType.getName() );
  -                throw new Exception( message );
  +                final String role = roles[ i ];
  +                final Class roleImplClass = Class.forName( role );
  +                roleRegistry.addRole( new RoleInfo( role, roleImplClass ) );
               }
  -
  -            return object;
  -        }
  -        catch( final IllegalAccessException iae )
  -        {
  -            final String message = REZ.getString( "bad-ctor.error",
  -                                                  roleType.getName(), className );
  -            throw new Exception( message );
  -        }
  -        catch( final InstantiationException ie )
  -        {
  -            final String message =
  -                REZ.getString( "no-instantiate.error", roleType.getName(), className );
  -            throw new Exception( message );
  -        }
  -        catch( final ClassNotFoundException cnfe )
  -        {
  -            final String message =
  -                REZ.getString( "no-class.error", roleType.getName(), className );
  -            throw new Exception( message );
           }
  +
  +        // Register the service
  +        final ServiceFactory factory = new DefaultServiceFactory( defaultImplClass, getClass().getClassLoader()
);
  +        final ServiceDescriptor descriptor = new ServiceDescriptor( roles, factory );
  +        serviceRegistry.registerService( descriptor );
       }
   
       /**
  
  
  
  1.7       +2 -9      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/Resources.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Resources.properties	7 Jun 2002 05:48:20 -0000	1.6
  +++ Resources.properties	15 Jun 2002 08:00:21 -0000	1.7
  @@ -1,9 +1,2 @@
  -bad-type.error=Object {0} is not an instance of {1}.
  -bad-ctor.error=Non-public constructor for {0} {1}.
  -no-instantiate.error=Error instantiating class for {0} {1}.
  -no-class.error=Could not find the class for {0} ({1}).
  -bad-filename.error=Unable to retrieve filename for file {0}.
  -create-project.error=Could not load the project definition from {0}.
  -
  -embeddor.corelib-count.notice=Deploying {0} core librarys.
  -embeddor.corelib-deployed.notice=Deploying Library named "{0}" with ClassPath={1}.
  \ No newline at end of file
  +embeddor.corelib-count.notice=Deploying {0} core libraries.
  +embeddor.corelib-deployed.notice=Deploying library "{0}" with class-path: {1}.
  \ No newline at end of file
  
  
  
  1.12      +55 -23    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/service/InstantiatingServiceManager.java
  
  Index: InstantiatingServiceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/service/InstantiatingServiceManager.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- InstantiatingServiceManager.java	15 Jun 2002 03:24:16 -0000	1.11
  +++ InstantiatingServiceManager.java	15 Jun 2002 08:00:21 -0000	1.12
  @@ -26,6 +26,7 @@
   import org.apache.myrmidon.interfaces.role.RoleManager;
   import org.apache.myrmidon.interfaces.service.ServiceFactory;
   import org.apache.myrmidon.interfaces.service.ServiceRegistry;
  +import org.apache.myrmidon.interfaces.service.ServiceDescriptor;
   
   /**
    * A service manager implementation, which creates service instances on demand.
  @@ -56,8 +57,8 @@
       /** Map from service class -> service object. */
       private final Map m_services = new HashMap();
   
  -    /** Map from role name -> service factory for that role. */
  -    private final Map m_factories = new HashMap();
  +    /** Map from role name -> ServiceDescriptor for that role. */
  +    private final Map m_descriptors = new HashMap();
   
       /** The objects (services and factories) that this mgr is responsible for. */
       private final List m_objects = new ArrayList();
  @@ -90,7 +91,7 @@
   
           // Ditch state
           m_services.clear();
  -        m_factories.clear();
  +        m_descriptors.clear();
           m_objects.clear();
       }
   
  @@ -107,29 +108,43 @@
       /**
        * Registers a service.
        */
  -    public void registerService( final String roleName,
  -                                 final ServiceFactory factory )
  +    public void registerService( final ServiceDescriptor descriptor )
           throws ServiceException
       {
  -        getLogger().info( "register service for " + roleName );
  -        if( m_factories.containsKey( roleName ) )
  +        // Check for collisions with other services
  +        final String[] roles = descriptor.getRoles();
  +        for( int i = 0; i < roles.length; i++ )
           {
  -            final String message = REZ.getString( "duplicate-factory-for-role.error", roleName
);
  -            throw new ServiceException( message );
  +            final String role = roles[ i ];
  +            if( m_descriptors.containsKey( role ) )
  +            {
  +                final String message = REZ.getString( "duplicate-factory-for-role.error",
role );
  +                throw new ServiceException( message );
  +            }
  +            if( m_services.containsKey( role ) )
  +            {
  +                final String message = REZ.getString( "duplicate-service-for-role.error",
role );
  +                throw new ServiceException( message );
  +            }
           }
   
           // Run the factory through the lifecycle
           // TODO - should be doing this somewhere else?
           try
           {
  -            setupObject( factory );
  +            setupObject( descriptor.getFactory() );
           }
           catch( Exception e )
           {
               throw new ServiceException( e.getMessage(), e );
           }
   
  -        m_factories.put( roleName, factory );
  +        // Register the service under the roles it provides
  +        for( int i = 0; i < roles.length; i++ )
  +        {
  +            final String role = roles[ i ];
  +            m_descriptors.put( role, descriptor );
  +        }
       }
   
       /**
  @@ -145,7 +160,7 @@
           }
           try
           {
  -            return ( getFactory( serviceRole ) != null );
  +            return ( getDescriptor( serviceRole ) != null );
           }
           catch( final Exception e )
           {
  @@ -157,11 +172,11 @@
       }
   
       /**
  -     * Locates the type factory to use to instantiate service factories.
  +     * Locates the descriptor for the service for a particular role.
        */
  -    private ServiceFactory getFactory( String roleName )
  +    private ServiceDescriptor getDescriptor( final String roleName )
       {
  -        return (ServiceFactory)m_factories.get( roleName );
  +        return (ServiceDescriptor)m_descriptors.get( roleName );
       }
   
       /**
  @@ -180,7 +195,6 @@
           {
               // Create the service
               service = createService( serviceRole );
  -            m_services.put( serviceRole, service );
           }
   
           return service;
  @@ -196,12 +210,16 @@
   
       /**
        * Creates the service object for a service role.
  +     *
  +     * @todo Check for recursive calls to this method, eg when the service
  +     *       being created calls lookup() for a service that is also being
  +     *       created.
        */
       private Object createService( final String serviceRole ) throws ServiceException
       {
  -        // Locate factory for service
  -        final ServiceFactory factory = getFactory( serviceRole );
  -        if( factory == null )
  +        // Locate descriptor for service
  +        final ServiceDescriptor descriptor = getDescriptor( serviceRole );
  +        if( descriptor == null )
           {
               final String message = REZ.getString( "unknown-service-type.error", serviceRole
);
               throw new ServiceException( message );
  @@ -209,10 +227,24 @@
   
           try
           {
  -            // Create the service
  -            final Object service = factory.createService();
  -            validateService( serviceRole, service );
  +            // Create, validate, and setup the service
  +            final Object service = descriptor.getFactory().createService();
  +            final String[] roles = descriptor.getRoles();
  +            for( int i = 0; i < roles.length; i++ )
  +            {
  +                final String role = roles[ i ];
  +                validateService( role, service );
  +            }
  +
               setupObject( service );
  +
  +            // Register the service
  +            for( int i = 0; i < roles.length; i++ )
  +            {
  +                final String role = roles[ i ];
  +                m_services.put( role, service );
  +            }
  +
               return service;
           }
           catch( final Exception e )
  
  
  
  1.4       +2 -1      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/service/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/service/Resources.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Resources.properties	15 Jun 2002 03:24:16 -0000	1.3
  +++ Resources.properties	15 Jun 2002 08:00:21 -0000	1.4
  @@ -1,4 +1,5 @@
   unknown-service-type.error=Unknown service "{0}".
   mismatched-service-type.error=Service factory for service "{0}" produced an object of unexpected
type {1}.
   create-service.error=Could not create service "{0}".
  -duplicate-factory-for-role.error=Multiple service factories registered for role "{0}".
  \ No newline at end of file
  +duplicate-factory-for-role.error=Multiple service factories registered for role "{0}".
  +duplicate-service-for-role.error=Attempting to register a service for role "{0}" when one
is already present.
  \ No newline at end of file
  
  
  
  1.2       +5 -2      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServiceDeployer.java	15 Jun 2002 03:24:16 -0000	1.1
  +++ ServiceDeployer.java	15 Jun 2002 08:00:21 -0000	1.2
  @@ -22,6 +22,8 @@
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    * @version $Revision$ $Date$
  + *
  + * @todo Handle services that provide more than one role.
    */
   public class ServiceDeployer
       implements TypeDeployer, Serviceable
  @@ -47,6 +49,7 @@
           final String name = typeDefinition.getName();
           final RoleInfo roleInfo = m_roleManager.getRoleByShortName( name );
           final ServiceFactory factory = (ServiceFactory)typeDefinition.getFactory().create(
name );
  -        m_serviceRegistry.registerService( roleInfo.getInterfaceName(), factory );
  +        final ServiceDescriptor descriptor = new ServiceDescriptor( roleInfo.getInterfaceName(),
factory );
  +        m_serviceRegistry.registerService( descriptor );
       }
   }
  
  
  
  1.3       +4 -5      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/service/ServiceRegistry.java
  
  Index: ServiceRegistry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/service/ServiceRegistry.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServiceRegistry.java	15 Jun 2002 03:24:16 -0000	1.2
  +++ ServiceRegistry.java	15 Jun 2002 08:00:21 -0000	1.3
  @@ -23,10 +23,9 @@
       /**
        * Register a service in runtime.
        *
  -     * @param roleName the role under which to register service.
  -     * @param factory the factory to use to create the service instance.
  -     * @throws ServiceException if error registering factory
  +     * @param serviceDescriptor The service to register.
  +     * @throws ServiceException if error registering factory.
        */
  -    void registerService( String roleName, ServiceFactory factory )
  +    void registerService( ServiceDescriptor serviceDescriptor )
           throws ServiceException;
   }
  
  
  
  1.10      +8 -4      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/service/test/InstantiatingServiceManagerTestCase.java
  
  Index: InstantiatingServiceManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/service/test/InstantiatingServiceManagerTestCase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- InstantiatingServiceManagerTestCase.java	15 Jun 2002 03:24:17 -0000	1.9
  +++ InstantiatingServiceManagerTestCase.java	15 Jun 2002 08:00:22 -0000	1.10
  @@ -15,6 +15,7 @@
   import org.apache.myrmidon.components.service.InstantiatingServiceManager;
   import org.apache.myrmidon.interfaces.role.RoleManager;
   import org.apache.myrmidon.interfaces.role.RoleInfo;
  +import org.apache.myrmidon.interfaces.service.ServiceDescriptor;
   
   /**
    * Test cases for the default service manager.
  @@ -56,7 +57,8 @@
       public void testCreateService() throws Exception
       {
           // Setup the test service
  -        m_serviceManager.registerService( TestService.ROLE, new TestServiceFactory1() );
  +        final ServiceDescriptor descriptor = new ServiceDescriptor( TestService.ROLE, new
TestServiceFactory1() );
  +        m_serviceManager.registerService( descriptor );
   
           // Create the service
           Object service = m_serviceManager.lookup( TestService.ROLE );
  @@ -71,7 +73,8 @@
       public void testLookup() throws Exception
       {
           // Setup the test service
  -        m_serviceManager.registerService( TestService.ROLE, new TestServiceFactory1() );
  +        final ServiceDescriptor descriptor = new ServiceDescriptor( TestService.ROLE, new
TestServiceFactory1() );
  +        m_serviceManager.registerService( descriptor );
   
           // Check whether the service can be instantiated
           boolean hasService = m_serviceManager.hasService( TestService.ROLE );
  @@ -85,7 +88,8 @@
       public void testLifecycle() throws Exception
       {
           // Setup the test service
  -        m_serviceManager.registerService( TestService.ROLE, new TestServiceFactory2() );
  +        final ServiceDescriptor descriptor = new ServiceDescriptor( TestService.ROLE, new
TestServiceFactory2() );
  +        m_serviceManager.registerService( descriptor );
   
           // Create the service
           TestService service = (TestService)m_serviceManager.lookup( TestService.ROLE );
  
  
  

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