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/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer DefaultDeployer.java Deployment.java Resources.properties ServiceDescriptorBuilder.java
Date Thu, 14 Feb 2002 02:07:02 GMT
adammurdoch    02/02/13 18:07:02

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer
                        DefaultDeployer.java Deployment.java
                        Resources.properties ServiceDescriptorBuilder.java
  Log:
  * Deployer now deploys services from META-INF/ant-services.xml
  * Embeddor now creates a ServiceManager component.
  
  Revision  Changes    Path
  1.24      +3 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java
  
  Index: DefaultEmbeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- DefaultEmbeddor.java	13 Feb 2002 03:02:54 -0000	1.23
  +++ DefaultEmbeddor.java	14 Feb 2002 02:07:02 -0000	1.24
  @@ -38,6 +38,7 @@
   import org.apache.myrmidon.interfaces.extensions.ExtensionManager;
   import org.apache.myrmidon.interfaces.model.Project;
   import org.apache.myrmidon.interfaces.role.RoleManager;
  +import org.apache.myrmidon.interfaces.service.ServiceManager;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeManager;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
  @@ -48,7 +49,7 @@
    * Instantiate this to embed inside other applications.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.23 $ $Date: 2002/02/13 03:02:54 $
  + * @version $Revision: 1.24 $ $Date: 2002/02/14 02:07:02 $
    */
   public class DefaultEmbeddor
       extends AbstractLogEnabled
  @@ -245,6 +246,7 @@
           createComponent( Deployer.class, PREFIX + "deployer.DefaultDeployer" );
           createComponent( ClassLoaderManager.class, PREFIX + "deployer.DefaultClassLoaderManager"
);
           createComponent( Executor.class, PREFIX + "executor.AspectAwareExecutor" );
  +        createComponent( ServiceManager.class, PREFIX + "service.DefaultServiceManager"
);
       }
   
       /**
  
  
  
  1.24      +31 -13    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultDeployer.java
  
  Index: DefaultDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultDeployer.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- DefaultDeployer.java	12 Feb 2002 10:40:08 -0000	1.23
  +++ DefaultDeployer.java	14 Feb 2002 02:07:02 -0000	1.24
  @@ -25,6 +25,8 @@
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
   import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
   import org.apache.myrmidon.interfaces.role.RoleManager;
  +import org.apache.myrmidon.interfaces.service.ServiceFactory;
  +import org.apache.myrmidon.interfaces.service.ServiceManager;
   import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeManager;
   
  @@ -33,7 +35,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.23 $ $Date: 2002/02/12 10:40:08 $
  + * @version $Revision: 1.24 $ $Date: 2002/02/14 02:07:02 $
    */
   public class DefaultDeployer
       extends AbstractLogEnabled
  @@ -50,6 +52,7 @@
   
       /** Map from ClassLoader to the deployer for that class loader. */
       private final Map m_classLoaderDeployers = new HashMap();
  +    private ServiceManager m_ServiceManager;
   
       /**
        * Retrieve relevent services needed to deploy.
  @@ -64,6 +67,7 @@
           m_typeManager = (TypeManager)componentManager.lookup( TypeManager.ROLE );
           m_roleManager = (RoleManager)componentManager.lookup( RoleManager.ROLE );
           m_classLoaderManager = (ClassLoaderManager)componentManager.lookup( ClassLoaderManager.ROLE
);
  +        m_ServiceManager = (ServiceManager)componentManager.lookup( ServiceManager.ROLE
);
       }
   
       /**
  @@ -136,6 +140,21 @@
       }
   
       /**
  +     * Deploys a service.
  +     */
  +    public void deployService( final Deployment deployment,
  +                               final ServiceDefinition definition )
  +        throws Exception
  +    {
  +        // Determine the service interface class name
  +        String serviceTypeName = getRoleForName( definition.getRoleShorthand() );
  +
  +        // Register the service factory
  +        final String factoryClassName = definition.getFactoryClass();
  +        handleType( deployment, ServiceFactory.class, serviceTypeName, factoryClassName
);
  +    }
  +
  +    /**
        * Handles a type definition.
        */
       public void deployType( final Deployment deployment,
  @@ -187,7 +206,16 @@
               }
   
               // Deploy general-purpose type
  -            handleType( deployment, roleShorthand, typeName, className );
  +            final String role = getRoleForName( roleShorthand );
  +            final Class roleType = deployment.getClassLoader().loadClass( role );
  +            handleType( deployment, roleType, typeName, className );
  +
  +            if( getLogger().isDebugEnabled() )
  +            {
  +                final String message =
  +                    REZ.getString( "register-type.notice", roleShorthand, typeName );
  +                getLogger().debug( message );
  +            }
           }
       }
   
  @@ -195,24 +223,15 @@
        * Handles a type definition.
        */
       private void handleType( final Deployment deployment,
  -                             final String roleShorthand,
  +                             final Class roleType,
                                final String typeName,
                                final String className )
           throws Exception
       {
           // TODO - detect duplicates
  -        final String role = getRoleForName( roleShorthand );
  -        final Class roleType = deployment.getClassLoader().loadClass( role );
           final DefaultTypeFactory factory = deployment.getFactory( roleType );
           factory.addNameClassMapping( typeName, className );
           m_typeManager.registerType( roleType, typeName, factory );
  -
  -        if( getLogger().isDebugEnabled() )
  -        {
  -            final String message =
  -                REZ.getString( "register-type.notice", roleShorthand, typeName );
  -            getLogger().debug( message );
  -        }
       }
   
       /**
  @@ -270,5 +289,4 @@
   
           return role;
       }
  -
   }
  
  
  
  1.20      +35 -1     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/Deployment.java
  
  Index: Deployment.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/Deployment.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Deployment.java	12 Feb 2002 10:40:08 -0000	1.19
  +++ Deployment.java	14 Feb 2002 02:07:02 -0000	1.20
  @@ -30,7 +30,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.19 $ $Date: 2002/02/12 10:40:08 $
  + * @version $Revision: 1.20 $ $Date: 2002/02/14 02:07:02 $
    */
   class Deployment
       extends AbstractLogEnabled
  @@ -136,11 +136,19 @@
       public void deployAll()
           throws DeploymentException
       {
  +        // Deploy types
           for( int i = 0; i < m_descriptors.length; i++ )
           {
               TypeDescriptor descriptor = m_descriptors[ i ];
               deployTypes( descriptor );
           }
  +
  +        // Deploy services
  +        for( int i = 0; i < m_services.length; i++ )
  +        {
  +            final ServiceDescriptor descriptor = m_services[ i ];
  +            deployServices( descriptor );
  +        }
       }
   
       /**
  @@ -295,4 +303,30 @@
           }
       }
   
  +    /**
  +     * Deploys all services from a typelib descriptor.
  +     */
  +    private void deployServices( final ServiceDescriptor descriptor )
  +        throws DeploymentException
  +    {
  +
  +        try
  +        {
  +            final String message = REZ.getString( "url-deploy-services.notice", descriptor.getUrl()
);
  +            getLogger().info( message );
  +
  +            // Deploy the services
  +            final ServiceDefinition[] definitions = descriptor.getDefinitions();
  +            for( int i = 0; i < definitions.length; i++ )
  +            {
  +                final ServiceDefinition definition = definitions[ i ];
  +                m_deployer.deployService( this, definition );
  +            }
  +        }
  +        catch( Exception e )
  +        {
  +            final String message = REZ.getString( "deploy-services.error", descriptor.getUrl()
);
  +            throw new DeploymentException( message, e );
  +        }
  +    }
   }
  
  
  
  1.9       +2 -0      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/Resources.properties,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Resources.properties	12 Feb 2002 10:40:08 -0000	1.8
  +++ Resources.properties	14 Feb 2002 02:07:02 -0000	1.9
  @@ -3,10 +3,12 @@
   register-role.notice=Registered role {0} with shorthand name {1}.
   url-deploy-types.notice=Registering types from "{0}".
   url-deploy-roles.notice=Registering roles from "{0}".
  +url-deploy-services.notice=Registering services from "{0}".
   
   deploy-from-classloader.error=Could not register types from ClassLoader.
   deploy-from-file.error=Could not register types from type library "{0}".
   deploy-types.error=Could not register types from "{0}".
  +deploy-services.error=Could not register services from "{0}".
   deploy-converter.error=Could not register converter that converts from {0} to {1}.
   deploy-type.error=Could not register type {0}/{1}.
   unknown-role4name.error=Unknown role "{0}".
  
  
  
  1.2       +15 -3     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/ServiceDescriptorBuilder.java
  
  Index: ServiceDescriptorBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/ServiceDescriptorBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServiceDescriptorBuilder.java	12 Feb 2002 10:40:08 -0000	1.1
  +++ ServiceDescriptorBuilder.java	14 Feb 2002 02:07:02 -0000	1.2
  @@ -17,7 +17,7 @@
    * Builds typelib service descriptors.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.1 $ $Date: 2002/02/12 10:40:08 $
  + * @version $Revision: 1.2 $ $Date: 2002/02/14 02:07:02 $
    */
   class ServiceDescriptorBuilder
       implements DescriptorBuilder
  @@ -45,9 +45,21 @@
                   throw new DeploymentException( message );
               }
   
  -            // TODO - populate the descriptor
  +            // Build the descriptor
  +            final ServiceDescriptor descriptor = new ServiceDescriptor( url );
   
  -            return new ServiceDescriptor( url );
  +            // Add the service definitions
  +            final Configuration[] elements = config.getChildren();
  +            for( int i = 0; i < elements.length; i++ )
  +            {
  +                final Configuration element = elements[ i ];
  +                final String roleShorthand = element.getName();
  +                final String factoryClassName = element.getAttribute( "factory" );
  +                final ServiceDefinition definition = new ServiceDefinition( roleShorthand,
factoryClassName, config );
  +                descriptor.addDefinition( definition );
  +            }
  +
  +            return descriptor;
           }
           catch( Exception e )
           {
  
  
  

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