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/factories ExecManagerFactory.java
Date Sat, 15 Jun 2002 03:24:17 GMT
adammurdoch    2002/06/14 20:24:17

  Modified:    container/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java
               container/src/java/org/apache/myrmidon/components/service
                        InstantiatingServiceManager.java
                        Resources.properties
               container/src/java/org/apache/myrmidon/interfaces/service
                        ServiceFactory.java ServiceRegistry.java
               container/src/test/org/apache/myrmidon/components/service/test
                        InstantiatingServiceManagerTestCase.java
                        TestService.java TestServiceFactory1.java
                        TestServiceFactory2.java
               framework/src/java/org/apache/myrmidon/framework/factories
                        ExecManagerFactory.java
  Added:       container/src/java/org/apache/myrmidon/interfaces/service
                        ServiceDeployer.java
  Removed:     container/src/java/org/apache/myrmidon/interfaces/service
                        AntServiceException.java
  Log:
  Start munging InstantiatingServiceManager into a scope-aware service kernel:
  
  * Implemented ServiceRegistry.  Now longer uses the TypeManager to create
    the services.
  
  * Added a deployer for ServiceFactory role, which registers the services
    using ServiceRegistry, rather than via TypeRegistry.
  
  * Use InstantiatingServiceManager as the root service manager in DefaultEmbeddor.
    Don't create one for each workspace (yet).
  
  * Changed ServiceRegistry.registerService() to take role + service factory.
  
  * ServiceFactory.createService() throws Exception, rather than AntServiceException.
  
  Revision  Changes    Path
  1.97      +7 -17     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.96
  retrieving revision 1.97
  diff -u -r1.96 -r1.97
  --- DefaultEmbeddor.java	13 Jun 2002 07:26:38 -0000	1.96
  +++ DefaultEmbeddor.java	15 Jun 2002 03:24:16 -0000	1.97
  @@ -43,6 +43,7 @@
   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;
  @@ -54,7 +55,6 @@
   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.MultiSourceServiceManager;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeManager;
   import org.apache.myrmidon.interfaces.type.TypeRegistry;
  @@ -87,7 +87,7 @@
       private Configurer m_configurer;
   
       private List m_components = new ArrayList();
  -    private DefaultServiceManager m_serviceManager = new DefaultServiceManager();
  +    private InstantiatingServiceManager m_serviceManager = new InstantiatingServiceManager();
       private Context m_context;
       private ExecutionFrame m_rootFrame;
       private TaskContext m_rootContext;
  @@ -120,20 +120,8 @@
                                                   final Project[] projects )
           throws Exception
       {
  -        // setup a service manager that creates the project services
  -        final ServiceManager projServiceManager =
  -            (ServiceManager)createService( ServiceManager.class,
  -                                           PREFIX + "service.InstantiatingServiceManager"
);
  -        setupObject( projServiceManager, m_serviceManager, null );
  -        m_components.add( projServiceManager );
  -
  -        final MultiSourceServiceManager msServiceManager =
  -            new MultiSourceServiceManager();
  -        msServiceManager.add( projServiceManager );
  -        msServiceManager.add( m_serviceManager );
  -
           final DefaultServiceManager manager =
  -            new DefaultServiceManager( msServiceManager );
  +            new DefaultServiceManager( m_serviceManager );
   
           // Create the property store
           final PropertyStore propStore = m_rootProps.createChildStore();
  @@ -295,6 +283,8 @@
       private void setupComponents()
           throws Exception
       {
  +        setupObject( m_serviceManager, m_serviceManager, null );
  +
           // Create the components
           createComponent( ExtensionManager.ROLE,
                            ExtensionManager.class,
  @@ -436,7 +426,7 @@
       /**
        * Creates a root property store.
        */
  -    private PropertyStore createBaseStore( final DefaultServiceManager serviceManager )
  +    private PropertyStore createBaseStore( final InstantiatingServiceManager serviceManager
)
           throws Exception
       {
           final DefaultPropertyStore store = new DefaultPropertyStore();
  
  
  
  1.11      +108 -65   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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- InstantiatingServiceManager.java	9 Jun 2002 13:25:40 -0000	1.10
  +++ InstantiatingServiceManager.java	15 Jun 2002 03:24:16 -0000	1.11
  @@ -15,20 +15,17 @@
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.container.ContainerUtil;
  +import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.ContextException;
  +import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
  -import org.apache.avalon.framework.service.Serviceable;
  -import org.apache.avalon.framework.context.Contextualizable;
  -import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.framework.context.ContextException;
  -import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.myrmidon.interfaces.role.RoleInfo;
   import org.apache.myrmidon.interfaces.role.RoleManager;
   import org.apache.myrmidon.interfaces.service.ServiceFactory;
  -import org.apache.myrmidon.interfaces.type.TypeException;
  -import org.apache.myrmidon.interfaces.type.TypeFactory;
  -import org.apache.myrmidon.interfaces.type.TypeManager;
  +import org.apache.myrmidon.interfaces.service.ServiceRegistry;
   
   /**
    * A service manager implementation, which creates service instances on demand.
  @@ -46,25 +43,25 @@
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    * @version $Revision$ $Date$
  + *
  + * @todo Make this a scoped service
    */
   public class InstantiatingServiceManager
       extends AbstractLogEnabled
  -    implements ServiceManager, Contextualizable, Serviceable, Disposable
  +    implements ServiceManager, Contextualizable, Disposable, ServiceRegistry
   {
       private static final Resources REZ =
           ResourceManager.getPackageResources( InstantiatingServiceManager.class );
   
       /** Map from service class -> service object. */
  -    private Map m_services = new HashMap();
  +    private final Map m_services = new HashMap();
   
  -    /** The objects (services and factories) that have been created by this mgr. */
  -    private List m_objects = new ArrayList();
  +    /** Map from role name -> service factory for that role. */
  +    private final Map m_factories = new HashMap();
  +
  +    /** The objects (services and factories) that this mgr is responsible for. */
  +    private final List m_objects = new ArrayList();
   
  -    /** Other services used by this service manager. */
  -    private TypeFactory m_typeFactory;
  -    private RoleManager m_roleManager;
  -    private ServiceManager m_serviceManager;
  -    private TypeManager m_typeManager;
       private Context m_context;
   
       public void contextualize( final Context context ) throws ContextException
  @@ -73,23 +70,6 @@
       }
   
       /**
  -     * Pass the <code>ServiceManager</code> to the <code>servicable</code>.
  -     * The <code>Servicable</code> implementation should use the specified
  -     * <code>ServiceManager</code> to acquire the components it needs for
  -     * execution.
  -     *
  -     * @param manager The <code>ServiceManager</code> which this
  -     *                <code>Servicable</code> uses.
  -     */
  -    public void service( final ServiceManager manager )
  -        throws ServiceException
  -    {
  -        m_serviceManager = manager;
  -        m_roleManager = (RoleManager)manager.lookup( RoleManager.ROLE );
  -        m_typeManager = (TypeManager)manager.lookup( TypeManager.ROLE );
  -    }
  -
  -    /**
        * Disposes this service manager, and all services created by it.
        */
       public void dispose()
  @@ -109,11 +89,47 @@
           }
   
           // Ditch state
  -        m_services = null;
  -        m_typeFactory = null;
  -        m_objects = null;
  -        m_roleManager = null;
  -        m_serviceManager = null;
  +        m_services.clear();
  +        m_factories.clear();
  +        m_objects.clear();
  +    }
  +
  +    /**
  +     * Adds a service to this service manager.  This is a temporary method.
  +     *
  +     * @todo Get rid of this method - use ServiceRegistry instead.
  +     */
  +    public void put( final String roleName, final Object service )
  +    {
  +        m_services.put( roleName, service );
  +    }
  +
  +    /**
  +     * Registers a service.
  +     */
  +    public void registerService( final String roleName,
  +                                 final ServiceFactory factory )
  +        throws ServiceException
  +    {
  +        getLogger().info( "register service for " + roleName );
  +        if( m_factories.containsKey( roleName ) )
  +        {
  +            final String message = REZ.getString( "duplicate-factory-for-role.error", roleName
);
  +            throw new ServiceException( message );
  +        }
  +
  +        // Run the factory through the lifecycle
  +        // TODO - should be doing this somewhere else?
  +        try
  +        {
  +            setupObject( factory );
  +        }
  +        catch( Exception e )
  +        {
  +            throw new ServiceException( e.getMessage(), e );
  +        }
  +
  +        m_factories.put( roleName, factory );
       }
   
       /**
  @@ -129,11 +145,13 @@
           }
           try
           {
  -            return getFactory().canCreate( serviceRole );
  +            return ( getFactory( serviceRole ) != null );
           }
  -        catch( TypeException e )
  +        catch( final Exception e )
           {
  -            // Throw away exception - yuck
  +            // Throw away exception
  +            final String message = REZ.getString( "ignore-exception.warn" );
  +            getLogger().warn( message, e );
           }
           return false;
       }
  @@ -141,13 +159,9 @@
       /**
        * Locates the type factory to use to instantiate service factories.
        */
  -    private TypeFactory getFactory() throws TypeException
  +    private ServiceFactory getFactory( String roleName )
       {
  -        if( m_typeFactory == null )
  -        {
  -            m_typeFactory = m_typeManager.getFactory( ServiceFactory.ROLE );
  -        }
  -        return m_typeFactory;
  +        return (ServiceFactory)m_factories.get( roleName );
       }
   
       /**
  @@ -156,6 +170,11 @@
       public Object lookup( final String serviceRole )
           throws ServiceException
       {
  +        if( serviceRole.equals( ServiceRegistry.ROLE ) )
  +        {
  +            return this;
  +        }
  +
           Object service = m_services.get( serviceRole );
           if( service == null )
           {
  @@ -172,6 +191,7 @@
        */
       public void release( final Object service )
       {
  +        // Ignore
       }
   
       /**
  @@ -179,25 +199,19 @@
        */
       private Object createService( final String serviceRole ) throws ServiceException
       {
  -        try
  +        // Locate factory for service
  +        final ServiceFactory factory = getFactory( serviceRole );
  +        if( factory == null )
           {
  -            // Create the factory
  -            final ServiceFactory factory = (ServiceFactory)getFactory().create( serviceRole
);
  -            setupObject( factory );
  +            final String message = REZ.getString( "unknown-service-type.error", serviceRole
);
  +            throw new ServiceException( message );
  +        }
   
  +        try
  +        {
               // Create the service
               final Object service = factory.createService();
  -
  -            // Check the service is assignable to the role type
  -            final RoleInfo roleInfo = m_roleManager.getRoleByShortName( serviceRole );
  -            final Class serviceType = roleInfo.getImplementationClass();
  -            if( serviceType != null && !serviceType.isInstance( service ) )
  -            {
  -                final String message = REZ.getString( "mismatched-service-type.error",
  -                                                      serviceRole, service.getClass().getName()
);
  -                throw new ServiceException( message );
  -            }
  -
  +            validateService( serviceRole, service );
               setupObject( service );
               return service;
           }
  @@ -209,6 +223,35 @@
       }
   
       /**
  +     * Validates a newly create service
  +     */
  +    private void validateService( final String serviceRole,
  +                                  final Object service )
  +        throws ServiceException
  +    {
  +        final RoleManager roleManager = (RoleManager)m_services.get( RoleManager.ROLE );
  +        if( roleManager == null )
  +        {
  +            return;
  +        }
  +
  +        final RoleInfo roleInfo = roleManager.getRoleByInterface( serviceRole );
  +        if( roleInfo == null )
  +        {
  +            // TODO - should this be an error?
  +            return;
  +        }
  +
  +        final Class serviceType = roleInfo.getImplementationClass();
  +        if( serviceType != null && !serviceType.isInstance( service ) )
  +        {
  +            final String message = REZ.getString( "mismatched-service-type.error",
  +                                                  serviceRole, service.getClass().getName()
);
  +            throw new ServiceException( message );
  +        }
  +    }
  +
  +    /**
        * Sets-up an object, taking it through the lifecycle steps.
        */
       private void setupObject( final Object object )
  @@ -216,7 +259,7 @@
       {
           ContainerUtil.enableLogging( object, getLogger() );
           ContainerUtil.contextualize( object, m_context );
  -        ContainerUtil.service( object, m_serviceManager );
  +        ContainerUtil.service( object, this );
           ContainerUtil.initialize( object );
           m_objects.add( object );
       }
  
  
  
  1.3       +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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Resources.properties	24 Feb 2002 07:43:37 -0000	1.2
  +++ Resources.properties	15 Jun 2002 03:24:16 -0000	1.3
  @@ -1,3 +1,4 @@
   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}".
  \ No newline at end of file
  +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
  
  
  
  1.8       +4 -3      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/service/ServiceFactory.java
  
  Index: ServiceFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/service/ServiceFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ServiceFactory.java	9 Jun 2002 13:06:29 -0000	1.7
  +++ ServiceFactory.java	15 Jun 2002 03:24:16 -0000	1.8
  @@ -16,6 +16,7 @@
    * @version $Revision$ $Date$
    *
    * @ant.role name="service-factory"
  + *           type-deployer="org.apache.myrmidon.interfaces.service.ServiceDeployer"
    */
   public interface ServiceFactory
   {
  @@ -27,8 +28,8 @@
        * This method is usually called after the factory has been
        * prepared and configured as appropriate.
        * @return The created service.
  -     * @throws AntServiceException If the service could not be created.
  +     * @throws Exception If the service could not be created.
        */
       Object createService()
  -        throws AntServiceException;
  +        throws Exception;
   }
  
  
  
  1.2       +5 -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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServiceRegistry.java	6 May 2002 10:38:02 -0000	1.1
  +++ ServiceRegistry.java	15 Jun 2002 03:24:16 -0000	1.2
  @@ -23,10 +23,10 @@
       /**
        * Register a service in runtime.
        *
  -     * @param roleName the role under which to register service
  -     * @param service the actual service to register
  -     * @throws ServiceException if error registering service
  +     * @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
        */
  -    void registerService( String roleName, Object service )
  +    void registerService( String roleName, ServiceFactory factory )
           throws ServiceException;
   }
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/service/ServiceDeployer.java
  
  Index: ServiceDeployer.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.myrmidon.interfaces.service;
  
  import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
  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.role.RoleInfo;
  import org.apache.avalon.framework.service.Serviceable;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.ServiceException;
  
  /**
   * Deploys services.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/15 03:24:16 $
   */
  public class ServiceDeployer
      implements TypeDeployer, Serviceable
  {
      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 )
          throws Exception
      {
          // Create and register the service factory
          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 );
      }
  }
  
  
  
  1.9       +14 -35    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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- InstantiatingServiceManagerTestCase.java	27 May 2002 08:30:30 -0000	1.8
  +++ InstantiatingServiceManagerTestCase.java	15 Jun 2002 03:24:17 -0000	1.9
  @@ -11,12 +11,10 @@
   import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.myrmidon.components.AbstractComponentTest;
  +import org.apache.myrmidon.components.role.DefaultRoleManager;
   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.role.RoleRegistry;
  -import org.apache.myrmidon.interfaces.service.ServiceFactory;
  -import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
  -import org.apache.myrmidon.interfaces.type.TypeRegistry;
   
   /**
    * Test cases for the default service manager.
  @@ -46,7 +44,10 @@
           m_serviceManager = new InstantiatingServiceManager();
           m_serviceManager.enableLogging( getLogger() );
           m_serviceManager.contextualize( new DefaultContext() );
  -        m_serviceManager.service( getServiceManager() );
  +
  +        final DefaultRoleManager roleManager = new DefaultRoleManager();
  +        m_serviceManager.put( RoleManager.ROLE, roleManager );
  +        roleManager.addRole( new RoleInfo( "test-service", TestService.class ) );
       }
   
       /**
  @@ -54,13 +55,11 @@
        */
       public void testCreateService() throws Exception
       {
  -        final String serviceRoleName = "test-service";
  -
           // Setup the test service
  -        registerFactory( serviceRoleName, TestService.class, TestServiceFactory1.class
);
  +        m_serviceManager.registerService( TestService.ROLE, new TestServiceFactory1() );
   
           // Create the service
  -        Object service = m_serviceManager.lookup( serviceRoleName );
  +        Object service = m_serviceManager.lookup( TestService.ROLE );
   
           // Check service is of the expected class (don't use instanceof)
           assertTrue( service.getClass() == TestServiceImpl1.class );
  @@ -71,13 +70,11 @@
        */
       public void testLookup() throws Exception
       {
  -        final String serviceRoleName = "test-service";
  -
           // Setup the test service
  -        registerFactory( serviceRoleName, TestService.class, TestServiceFactory1.class
);
  +        m_serviceManager.registerService( TestService.ROLE, new TestServiceFactory1() );
   
           // Check whether the service can be instantiated
  -        boolean hasService = m_serviceManager.hasService( serviceRoleName );
  +        boolean hasService = m_serviceManager.hasService( TestService.ROLE );
           assertTrue( hasService );
       }
   
  @@ -87,13 +84,11 @@
        */
       public void testLifecycle() throws Exception
       {
  -        final String serviceRoleName = "test-service";
  -
           // Setup the test service
  -        registerFactory( serviceRoleName, TestService.class, TestServiceFactory2.class
);
  +        m_serviceManager.registerService( TestService.ROLE, new TestServiceFactory2() );
   
           // Create the service
  -        TestService service = (TestService)m_serviceManager.lookup( serviceRoleName );
  +        TestService service = (TestService)m_serviceManager.lookup( TestService.ROLE );
   
           // Check service is of the expected class (don't use instanceof)
           assertTrue( service.getClass() == TestServiceImpl2.class );
  @@ -126,24 +121,8 @@
           }
           catch( ServiceException e )
           {
  -            final String message = REZ.getString( "create-service.error", serviceRole );
  +            final String message = REZ.getString( "unknown-service-type.error", serviceRole
);
               assertSameMessage( message, e );
           }
  -    }
  -
  -    /**
  -     * Registers a service factory.
  -     */
  -    private void registerFactory( final String serviceRoleName,
  -                                  final Class serviceType,
  -                                  final Class factoryClass )
  -        throws Exception
  -    {
  -        // TODO - add stuff to TypeDeployer to do this instead
  -        final RoleRegistry roleRegistry = (RoleRegistry)getServiceManager().lookup( RoleRegistry.ROLE
);
  -        roleRegistry.addRole( new RoleInfo( serviceRoleName, serviceType ) );
  -        final DefaultTypeFactory typeFactory = new DefaultTypeFactory( serviceRoleName,
factoryClass );
  -        final TypeRegistry typeRegistry = (TypeRegistry)getServiceManager().lookup( TypeRegistry.ROLE
);
  -        typeRegistry.registerType( ServiceFactory.ROLE, null, serviceRoleName, typeFactory
);
       }
   }
  
  
  
  1.2       +3 -1      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/service/test/TestService.java
  
  Index: TestService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/service/test/TestService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestService.java	17 Mar 2002 08:07:10 -0000	1.1
  +++ TestService.java	15 Jun 2002 03:24:17 -0000	1.2
  @@ -15,5 +15,7 @@
    */
   public interface TestService
   {
  +    String ROLE = TestService.class.getName();
  +
       void doWork();
   }
  
  
  
  1.2       +1 -3      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/service/test/TestServiceFactory1.java
  
  Index: TestServiceFactory1.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/service/test/TestServiceFactory1.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestServiceFactory1.java	17 Mar 2002 08:07:10 -0000	1.1
  +++ TestServiceFactory1.java	15 Jun 2002 03:24:17 -0000	1.2
  @@ -7,7 +7,6 @@
    */
   package org.apache.myrmidon.components.service.test;
   
  -import org.apache.myrmidon.interfaces.service.AntServiceException;
   import org.apache.myrmidon.interfaces.service.ServiceFactory;
   
   /**
  @@ -23,7 +22,6 @@
        * Create a service that coresponds to this factory.
        */
       public Object createService()
  -        throws AntServiceException
       {
           return new TestServiceImpl1();
       }
  
  
  
  1.2       +1 -4      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/service/test/TestServiceFactory2.java
  
  Index: TestServiceFactory2.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/service/test/TestServiceFactory2.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestServiceFactory2.java	17 Mar 2002 08:07:10 -0000	1.1
  +++ TestServiceFactory2.java	15 Jun 2002 03:24:17 -0000	1.2
  @@ -7,9 +7,7 @@
    */
   package org.apache.myrmidon.components.service.test;
   
  -import org.apache.myrmidon.interfaces.service.AntServiceException;
   import org.apache.myrmidon.interfaces.service.ServiceFactory;
  -import org.apache.myrmidon.components.service.test.LifecycleValidator;
   
   /**
    * A test service factory, which asserts that the factory has been properly
  @@ -26,7 +24,6 @@
        * Create a service that corresponds to this factory.
        */
       public Object createService()
  -        throws AntServiceException
       {
           assertSetup();
           return new TestServiceImpl2();
  
  
  
  1.3       +3 -11     jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/factories/ExecManagerFactory.java
  
  Index: ExecManagerFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/factories/ExecManagerFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExecManagerFactory.java	26 Apr 2002 03:22:24 -0000	1.2
  +++ ExecManagerFactory.java	15 Jun 2002 03:24:17 -0000	1.3
  @@ -12,7 +12,6 @@
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
  -import org.apache.myrmidon.interfaces.service.AntServiceException;
   import org.apache.myrmidon.interfaces.service.ServiceFactory;
   
   /**
  @@ -37,15 +36,8 @@
        * Create the ExecManager Service.
        */
       public Object createService()
  -        throws AntServiceException
  +        throws Exception
       {
  -        try
  -        {
  -            return new DefaultExecManager( m_homeDir );
  -        }
  -        catch( final Exception ee )
  -        {
  -            throw new AntServiceException( ee.getMessage(), ee );
  -        }
  +        return new DefaultExecManager( m_homeDir );
       }
   }
  
  
  

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