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 AbstractTypeDef.java
Date Thu, 25 Apr 2002 01:41:51 GMT
adammurdoch    02/04/24 18:41:51

  Modified:    .        build.xml
               antlib/src/java/org/apache/antlib/runtime Import.java
               container/src/java/org/apache/myrmidon/components/deployer
                        DefaultDeployer.java Resources.properties
                        ServiceDescriptorBuilder.java
               container/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java
               container/src/java/org/apache/myrmidon/components/role
                        DefaultRoleManager.java
               container/src/java/org/apache/myrmidon/components/workspace
                        DefaultWorkspace.java
               container/src/java/org/apache/myrmidon/interfaces/classloader
                        ClassLoaderManager.java
               container/src/java/org/apache/myrmidon/interfaces/deployer
                        Deployer.java
               container/src/java/org/apache/myrmidon/interfaces/role
                        RoleManager.java
               container/src/test/org/apache/myrmidon/components
                        AbstractComponentTest.java
               container/src/test/org/apache/myrmidon/components/deployer/test
                        DefaultDeployerTestCase.java
               container/src/test/org/apache/myrmidon/components/role/test
                        DefaultRoleManagerTestCase.java
               container/src/test/org/apache/myrmidon/components/service/test
                        InstantiatingServiceManagerTestCase.java
               framework/src/java/org/apache/myrmidon/framework
                        AbstractTypeDef.java
  Added:       container/src/java/org/apache/myrmidon/components/deployer
                        CompoundTypeDeployer.java
                        ConverterTypeDeployer.java DefaultTypeDeployer.java
                        DefaultTypeLibraryDeployer.java TypeDeployer.java
               container/src/java/org/apache/myrmidon/interfaces/deployer
                        TypeLibraryDeployer.java
               container/src/java/org/apache/myrmidon/interfaces/role
                        RoleRegistry.java
  Removed:     container/src/java/org/apache/myrmidon/components/deployer
                        Deployment.java ServiceDefinition.java
                        ServiceDescriptor.java
               container/src/java/org/apache/myrmidon/interfaces/deployer
                        TypeDeployer.java
  Log:
  * Moved RoleManager.addRole() to new RoleRegistry service interface.
  
  * Renamed TypeDeployer to TypeLibraryDeployer.
  
  * Added TypeDeployer, which handles role specific actions that need to happen
    when a type is deployed.  Moved all the role specific stuff out of
    DefaultDeployer and into several TypeDeployer implementations.
  
  * Treat services as types (internally at least), to reuse the type deployment
    stuff.
  
  Revision  Changes    Path
  1.12      +5 -0      jakarta-ant-myrmidon/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/build.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- build.xml	23 Apr 2002 06:27:07 -0000	1.11
  +++ build.xml	25 Apr 2002 01:41:49 -0000	1.12
  @@ -62,6 +62,11 @@
               <param name="target" value="rebuild"/>
           </antcall>
       </target>
  +    <target name="recompile" description="Rebuilds all projects">
  +        <antcall target="for-all-projects">
  +            <param name="target" value="recompile"/>
  +        </antcall>
  +    </target>
       <target name="test" description="Runs unit tests for all projects">
           <antcall target="for-all-projects">
               <param name="target" value="test"/>
  
  
  
  1.2       +2 -2      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/Import.java
  
  Index: Import.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/runtime/Import.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Import.java	14 Apr 2002 10:55:08 -0000	1.1
  +++ Import.java	25 Apr 2002 01:41:49 -0000	1.2
  @@ -14,7 +14,7 @@
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.deployer.DeploymentException;
  -import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
  +import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
   
   /**
    * Task to import a tasklib.
  @@ -47,7 +47,7 @@
           try
           {
               final Deployer deployer = (Deployer)getService( Deployer.class );
  -            final TypeDeployer typeDeployer = deployer.createDeployer( m_lib );
  +            final TypeLibraryDeployer typeDeployer = deployer.createDeployer( m_lib );
               typeDeployer.deployAll();
           }
           catch( final DeploymentException de )
  
  
  
  1.38      +20 -154   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.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- DefaultDeployer.java	24 Apr 2002 02:20:59 -0000	1.37
  +++ DefaultDeployer.java	25 Apr 2002 01:41:49 -0000	1.38
  @@ -19,24 +19,17 @@
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.myrmidon.interfaces.classloader.ClassLoaderManager;
  -import org.apache.myrmidon.interfaces.converter.ConverterRegistry;
  -import org.apache.myrmidon.interfaces.deployer.ConverterDefinition;
   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.deployer.TypeDeployer;
  -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.DefaultTypeFactory;
  -import org.apache.myrmidon.interfaces.type.TypeManager;
  +import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
  +import org.apache.myrmidon.interfaces.role.RoleRegistry;
   
   /**
    * This class deploys roles, types and services from a typelib.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.37 $ $Date: 2002/04/24 02:20:59 $
  + * @version $Revision: 1.38 $ $Date: 2002/04/25 01:41:49 $
    */
   public class DefaultDeployer
       extends AbstractLogEnabled
  @@ -46,10 +39,9 @@
           ResourceManager.getPackageResources( DefaultDeployer.class );
   
       // The components used to deploy
  -    private ConverterRegistry m_converterRegistry;
  -    private TypeManager m_typeManager;
  -    private RoleManager m_roleManager;
  +    private RoleRegistry m_roleManager;
       private ClassLoaderManager m_classLoaderManager;
  +    private CompoundTypeDeployer m_deployer;
   
       /** Map from ClassLoader to the deployer for that class loader. */
       private final Map m_classLoaderDeployers = new HashMap();
  @@ -63,10 +55,16 @@
       public void service( final ServiceManager serviceManager )
           throws ServiceException
       {
  -        m_converterRegistry = (ConverterRegistry)serviceManager.lookup( ConverterRegistry.ROLE );
  -        m_typeManager = (TypeManager)serviceManager.lookup( TypeManager.ROLE );
  -        m_roleManager = (RoleManager)serviceManager.lookup( RoleManager.ROLE );
  +        m_roleManager = (RoleRegistry)serviceManager.lookup( RoleRegistry.ROLE );
           m_classLoaderManager = (ClassLoaderManager)serviceManager.lookup( ClassLoaderManager.ROLE );
  +
  +        // Assemble the type deployer
  +        final DefaultTypeDeployer defaultDeployer = new DefaultTypeDeployer();
  +        defaultDeployer.service( serviceManager );
  +        final ConverterTypeDeployer converterDeployer = new ConverterTypeDeployer();
  +        converterDeployer.service( serviceManager );
  +        m_deployer = new CompoundTypeDeployer( defaultDeployer );
  +        m_deployer.addDeployer( Converter.ROLE, converterDeployer );
       }
   
       /**
  @@ -85,7 +83,7 @@
        * Returns the deployer for a ClassLoader, creating the deployer if
        * necessary.
        */
  -    public TypeDeployer createDeployer( final ClassLoader loader )
  +    public TypeLibraryDeployer createDeployer( final ClassLoader loader )
           throws DeploymentException
       {
           try
  @@ -103,7 +101,7 @@
        * Returns the deployer for a type library, creating the deployer if
        * necessary.
        */
  -    public TypeDeployer createDeployer( final File file )
  +    public TypeLibraryDeployer createDeployer( final File file )
           throws DeploymentException
       {
           try
  @@ -121,152 +119,20 @@
       /**
        * Creates a deployer for a ClassLoader.
        */
  -    private Deployment createDeployment( final ClassLoader loader,
  -                                         final URL jarUrl )
  +    private DefaultTypeLibraryDeployer createDeployment( final ClassLoader loader,
  +                                                         final URL jarUrl )
           throws Exception
       {
           // Locate cached deployer, creating it if necessary
  -        Deployment deployment = (Deployment)m_classLoaderDeployers.get( loader );
  +        DefaultTypeLibraryDeployer deployment = (DefaultTypeLibraryDeployer)m_classLoaderDeployers.get( loader );
           if( deployment == null )
           {
  -            deployment = new Deployment( this, loader );
  +            deployment = new DefaultTypeLibraryDeployer( m_roleManager, m_deployer, loader );
               setupLogger( deployment );
               deployment.loadDescriptors( jarUrl );
               m_classLoaderDeployers.put( loader, deployment );
           }
   
           return deployment;
  -    }
  -
  -    /**
  -     * Deploys a service.
  -     */
  -    public void deployService( final Deployment deployment,
  -                               final ServiceDefinition definition )
  -        throws Exception
  -    {
  -        final String roleName = definition.getRole();
  -        final String factoryClassName = definition.getFactoryClass();
  -        handleType( deployment, ServiceFactory.ROLE, roleName, factoryClassName );
  -    }
  -
  -    /**
  -     * Handles a type definition.
  -     */
  -    public void deployType( final Deployment deployment,
  -                            final TypeDefinition typeDef )
  -        throws Exception
  -    {
  -        final String typeName = typeDef.getName();
  -        final String roleName = typeDef.getRole();
  -
  -        final String className = typeDef.getClassname();
  -        if( null == className )
  -        {
  -            final String message = REZ.getString( "typedef.no-classname.error" );
  -            throw new DeploymentException( message );
  -        }
  -
  -        if( typeDef instanceof ConverterDefinition )
  -        {
  -            // Validate the definition
  -            final ConverterDefinition converterDef = (ConverterDefinition)typeDef;
  -            final String srcClass = converterDef.getSourceType();
  -            final String destClass = converterDef.getDestinationType();
  -            if( null == srcClass )
  -            {
  -                final String message = REZ.getString( "converterdef.no-source.error" );
  -                throw new DeploymentException( message );
  -            }
  -            if( null == destClass )
  -            {
  -                final String message = REZ.getString( "converterdef.no-destination.error" );
  -                throw new DeploymentException( message );
  -            }
  -
  -            // Deploy the converter
  -            handleConverter( deployment, className, srcClass, destClass );
  -        }
  -        else
  -        {
  -            // Validate the definition
  -            if( null == roleName )
  -            {
  -                final String message = REZ.getString( "typedef.no-role.error" );
  -                throw new DeploymentException( message );
  -            }
  -            else if( null == typeName )
  -            {
  -                final String message = REZ.getString( "typedef.no-name.error" );
  -                throw new DeploymentException( message );
  -            }
  -
  -            // Deploy general-purpose type
  -            handleType( deployment, roleName, typeName, className );
  -
  -            if( getLogger().isDebugEnabled() )
  -            {
  -                final String message =
  -                    REZ.getString( "register-type.notice", roleName, typeName );
  -                getLogger().debug( message );
  -            }
  -        }
  -    }
  -
  -    /**
  -     * Handles a type definition.
  -     */
  -    private void handleType( final Deployment deployment,
  -                             final String roleName,
  -                             final String typeName,
  -                             final String className )
  -        throws Exception
  -    {
  -        // TODO - detect duplicates
  -        final DefaultTypeFactory factory = deployment.getFactory( roleName );
  -        factory.addNameClassMapping( typeName, className );
  -        m_typeManager.registerType( roleName, typeName, factory );
  -    }
  -
  -    /**
  -     * Handles a converter definition.
  -     */
  -    private void handleConverter( final Deployment deployment,
  -                                  final String className,
  -                                  final String source,
  -                                  final String destination )
  -        throws Exception
  -    {
  -        m_converterRegistry.registerConverter( className, source, destination );
  -        final DefaultTypeFactory factory = deployment.getFactory( Converter.ROLE );
  -        factory.addNameClassMapping( className, className );
  -        m_typeManager.registerType( Converter.ROLE, className, factory );
  -
  -        if( getLogger().isDebugEnabled() )
  -        {
  -            final String message =
  -                REZ.getString( "register-converter.notice", source, destination );
  -            getLogger().debug( message );
  -        }
  -    }
  -
  -    /**
  -     * Handles a role definition.
  -     */
  -    public void deployRole( final Deployment deployment,
  -                            final RoleDefinition roleDef )
  -        throws Exception
  -    {
  -        final String role = roleDef.getRoleName();
  -        final String className = roleDef.getClassName();
  -        final Class type = deployment.getClassLoader().loadClass( className );
  -        final RoleInfo roleInfo = new RoleInfo( role, type, null );
  -        m_roleManager.addRole( roleInfo );
  -
  -        if( getLogger().isDebugEnabled() )
  -        {
  -            final String debugMessage = REZ.getString( "register-role.notice", role, className );
  -            getLogger().debug( debugMessage );
  -        }
       }
   }
  
  
  
  1.14      +0 -1      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/Resources.properties,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Resources.properties	24 Apr 2002 02:20:59 -0000	1.13
  +++ Resources.properties	25 Apr 2002 01:41:49 -0000	1.14
  @@ -1,4 +1,3 @@
  -register-converter.notice=Registered converter that converts from {0} to {1}.
   register-type.notice=Registered type {0}/{1}.
   register-role.notice=Registered role {0} with class name {1}.
   url-deploy-types.notice=Registering types from "{0}".
  
  
  
  1.8       +6 -4      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/ServiceDescriptorBuilder.java
  
  Index: ServiceDescriptorBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/ServiceDescriptorBuilder.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ServiceDescriptorBuilder.java	24 Apr 2002 02:20:59 -0000	1.7
  +++ ServiceDescriptorBuilder.java	25 Apr 2002 01:41:50 -0000	1.8
  @@ -12,12 +12,14 @@
   import org.apache.avalon.framework.Version;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.myrmidon.interfaces.deployer.DeploymentException;
  +import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  +import org.apache.myrmidon.interfaces.service.ServiceFactory;
   
   /**
    * Builds typelib service descriptors.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.7 $ $Date: 2002/04/24 02:20:59 $
  + * @version $Revision: 1.8 $ $Date: 2002/04/25 01:41:50 $
    */
   class ServiceDescriptorBuilder
       implements DescriptorBuilder
  @@ -47,7 +49,7 @@
               }
   
               // Build the descriptor
  -            final ServiceDescriptor descriptor = new ServiceDescriptor( url );
  +            final TypeDescriptor descriptor = new TypeDescriptor( url );
   
               // Add the service definitions
               final Configuration[] elements = model.getChildren();
  @@ -56,8 +58,8 @@
                   final Configuration element = elements[ i ];
                   final String roleName = element.getName();
                   final String factoryClassName = element.getAttribute( "factory" );
  -                final ServiceDefinition definition =
  -                    new ServiceDefinition( roleName, factoryClassName, model );
  +                final TypeDefinition definition =
  +                    new TypeDefinition( roleName, ServiceFactory.ROLE, factoryClassName );
                   descriptor.addDefinition( definition );
               }
   
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/CompoundTypeDeployer.java
  
  Index: CompoundTypeDeployer.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.components.deployer;
  
  import java.util.Map;
  import java.util.HashMap;
  import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  import org.apache.myrmidon.interfaces.type.TypeFactory;
  
  /**
   * A type deployer that delegates to a type deployer per role.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/25 01:41:49 $
   */
  public class CompoundTypeDeployer
      implements TypeDeployer
  {
      private final Map m_deployers = new HashMap();
      private final TypeDeployer m_defaultDeployer;
  
      public CompoundTypeDeployer( final TypeDeployer defaultDeployer )
      {
          m_defaultDeployer = defaultDeployer;
      }
  
      /**
       * Adds a deployer for a role.
       */
      public void addDeployer( final String role, final TypeDeployer deployer )
      {
          m_deployers.put( role, deployer );
      }
  
      /**
       * Deploys a type.
       */
      public void deployType( final TypeDefinition typeDefinition,
                              final TypeFactory typeFactory )
          throws Exception
      {
          // Use the deployer for the type's role, if any.  Otherwise use the
          // default deployer
          TypeDeployer deployer = (TypeDeployer)m_deployers.get( typeDefinition.getRole() );
          if( deployer == null )
          {
              deployer = m_defaultDeployer;
          }
          deployer.deployType( typeDefinition, typeFactory );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/ConverterTypeDeployer.java
  
  Index: ConverterTypeDeployer.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.components.deployer;
  
  import org.apache.avalon.framework.service.Serviceable;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  import org.apache.myrmidon.interfaces.deployer.ConverterDefinition;
  import org.apache.myrmidon.interfaces.type.TypeFactory;
  import org.apache.myrmidon.interfaces.converter.ConverterRegistry;
  
  /**
   * A type deployer that deploys converters, registering them with the type
   * manager and the converter registry.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/25 01:41:49 $
   */
  public class ConverterTypeDeployer
      extends DefaultTypeDeployer
      implements TypeDeployer, Serviceable
  {
      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 TypeDefinition typeDefinition,
                              final TypeFactory typeFactory )
          throws Exception
      {
          // Add the converter to the converter registry
          final ConverterDefinition converterDefinition = (ConverterDefinition)typeDefinition;
          final String name = converterDefinition.getName();
          final String source = converterDefinition.getSourceType();
          final String destination = converterDefinition.getDestinationType();
          if( null == source )
          {
              final String message = REZ.getString( "converterdef.no-source.error" );
              throw new Exception( message );
          }
          if( null == destination )
          {
              final String message = REZ.getString( "converterdef.no-destination.error" );
              throw new Exception( message );
          }
  
          m_converterRegistry.registerConverter( name, source, destination );
  
          // Register the converter as a type
          super.deployType( typeDefinition, typeFactory );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultTypeDeployer.java
  
  Index: DefaultTypeDeployer.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.components.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.interfaces.deployer.TypeDefinition;
  import org.apache.myrmidon.interfaces.type.TypeFactory;
  import org.apache.myrmidon.interfaces.type.TypeManager;
  
  /**
   * A general-purpose type deployer, which registers the type with the type
   * manager.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/25 01:41:49 $
   */
  public class DefaultTypeDeployer
      implements TypeDeployer, Serviceable
  {
      private TypeManager m_typeManager;
  
      public void service( final ServiceManager serviceManager )
          throws ServiceException
      {
          m_typeManager = (TypeManager)serviceManager.lookup( TypeManager.ROLE );
      }
  
      /**
       * Deploys a type.
       */
      public void deployType( final TypeDefinition typeDefinition,
                              final TypeFactory typeFactory )
          throws Exception
      {
          final String roleName = typeDefinition.getRole();
          final String typeName = typeDefinition.getName();
          m_typeManager.registerType( roleName, typeName, typeFactory );
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultTypeLibraryDeployer.java
  
  Index: DefaultTypeLibraryDeployer.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.components.deployer;
  
  import java.io.FileNotFoundException;
  import java.net.URL;
  import java.util.ArrayList;
  import java.util.Enumeration;
  import java.util.HashMap;
  import java.util.Map;
  import javax.xml.parsers.SAXParser;
  import javax.xml.parsers.SAXParserFactory;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.myrmidon.interfaces.deployer.DeploymentException;
  import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
  import org.apache.myrmidon.interfaces.role.RoleInfo;
  import org.apache.myrmidon.interfaces.role.RoleRegistry;
  import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
  import org.xml.sax.XMLReader;
  
  /**
   * A type library deployer implementation.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/25 01:41:49 $
   */
  class DefaultTypeLibraryDeployer
      extends AbstractLogEnabled
      implements TypeLibraryDeployer
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( DefaultTypeLibraryDeployer.class );
  
      private static final String TYPE_DESCRIPTOR_NAME = "META-INF/ant-descriptor.xml";
      private static final String ROLE_DESCRIPTOR_NAME = "META-INF/ant-roles.xml";
      private static final String SERVICE_DESCRIPTOR_NAME = "META-INF/ant-services.xml";
  
      private final TypeDeployer m_typeDeployer;
      private final ClassLoader m_classLoader;
      private TypeDescriptor[] m_descriptors;
      private TypeDescriptor[] m_services;
  
      // TODO - create and configure these in DefaultDeployer
      private DescriptorBuilder m_roleBuilder = new RoleDescriptorBuilder();
      private DescriptorBuilder m_typeBuilder = new TypeDescriptorBuilder();
      private DescriptorBuilder m_serviceBuilder = new ServiceDescriptorBuilder();
  
      /** Map from role Class -> DefaultTypeFactory for that role. */
      private Map m_factories = new HashMap();
      private final RoleRegistry m_roleRegistry;
  
      public DefaultTypeLibraryDeployer( final RoleRegistry roleRegistry,
                                         final TypeDeployer typeDeployer,
                                         final ClassLoader classLoader )
      {
          m_roleRegistry = roleRegistry;
          m_typeDeployer = typeDeployer;
          m_classLoader = classLoader;
      }
  
      /**
       * Load the descriptors.  Deploys all roles, then loads the descriptors
       * for, but does not deploy, all the types.
       *
       * @param jarUrl The URL for the typelib, used to locate the descriptors.
       *               If null, the resources from the classloader are used.
       */
      public void loadDescriptors( final URL jarUrl )
          throws Exception
      {
          // Create a SAX parser to assemble the descriptors into Configuration
          // objects
          final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
          final SAXParser saxParser = saxParserFactory.newSAXParser();
          final XMLReader parser = saxParser.getXMLReader();
          //parser.setFeature( "http://xml.org/sax/features/namespace-prefixes", false );
  
          final SAXConfigurationHandler handler = new SAXConfigurationHandler();
          parser.setContentHandler( handler );
          parser.setErrorHandler( handler );
  
          // Build the role descriptors
          final ArrayList roleUrls = locateResources( ROLE_DESCRIPTOR_NAME, jarUrl );
          final ArrayList roleDescriptors =
              buildDescriptors( roleUrls, m_roleBuilder, parser, handler );
  
          // Deploy the roles
          // TODO - need to defer this
          final int roleCount = roleDescriptors.size();
          for( int i = 0; i < roleCount; i++ )
          {
              final RoleDescriptor descriptor = (RoleDescriptor)roleDescriptors.get( i );
              deployRoles( descriptor );
          }
  
          // Build the type descriptors
          final ArrayList typeUrls = locateResources( TYPE_DESCRIPTOR_NAME, jarUrl );
          final ArrayList typeDescriptors =
              buildDescriptors( typeUrls, m_typeBuilder, parser, handler );
          m_descriptors = (TypeDescriptor[])typeDescriptors.toArray
              ( new TypeDescriptor[ typeDescriptors.size() ] );
  
          // Build the service descriptors
          final ArrayList serviceUrls = locateResources( SERVICE_DESCRIPTOR_NAME, jarUrl );
          final ArrayList serviceDescriptors =
              buildDescriptors( serviceUrls, m_serviceBuilder, parser, handler );
          m_services = (TypeDescriptor[])serviceDescriptors.toArray
              ( new TypeDescriptor[ serviceDescriptors.size() ] );
      }
  
      /**
       * Returns the type factory for a role.
       */
      public DefaultTypeFactory getFactory( final String roleName )
      {
          DefaultTypeFactory factory = (DefaultTypeFactory)m_factories.get( roleName );
  
          if( null == factory )
          {
              factory = new DefaultTypeFactory( m_classLoader );
              m_factories.put( roleName, factory );
          }
  
          return factory;
      }
  
      /**
       * Returns the classloader for this deployment.
       */
      public ClassLoader getClassLoader()
      {
          return m_classLoader;
      }
  
      /**
       * Deploys everything in the type library.
       */
      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 TypeDescriptor descriptor = m_services[ i ];
              deployServices( descriptor );
          }
      }
  
      /**
       * Deploys a single type in the type library.
       */
      public void deployType( final String roleName, final String typeName )
          throws DeploymentException
      {
          try
          {
              // Locate the definition for the type
              for( int i = 0; i < m_descriptors.length; i++ )
              {
                  final TypeDescriptor descriptor = m_descriptors[ i ];
                  final TypeDefinition[] definitions = descriptor.getDefinitions();
                  for( int j = 0; j < definitions.length; j++ )
                  {
                      TypeDefinition definition = definitions[ j ];
                      if( definition.getRole().equals( roleName )
                          && definition.getName().equals( typeName ) )
                      {
                          // Found the definition - deploy it.  Note that we
                          // keep looking for matching types, and let the deployer
                          // deal with duplicates
                          doDeployType( definition );
                      }
                  }
              }
          }
          catch( Exception e )
          {
              final String message = REZ.getString( "deploy-type.error", roleName, typeName );
              throw new DeploymentException( message, e );
          }
      }
  
      /**
       * Deploys a single type from the type library.
       */
      public void deployType( final TypeDefinition typeDef )
          throws DeploymentException
      {
          try
          {
              doDeployType( typeDef );
          }
          catch( Exception e )
          {
              final String message = REZ.getString( "deploy-type.error",
                                                    typeDef.getRole(), typeDef.getName() );
              throw new DeploymentException( message, e );
          }
      }
  
      /**
       * Deploys a type.
       */
      private void doDeployType( final TypeDefinition typeDef ) throws Exception
      {
          // Validate the type definition
          final String typeName = typeDef.getName();
          final String roleName = typeDef.getRole();
          final String className = typeDef.getClassname();
          if( null == roleName )
          {
              final String message = REZ.getString( "typedef.no-role.error" );
              throw new DeploymentException( message );
          }
          if( null == typeName )
          {
              final String message = REZ.getString( "typedef.no-name.error" );
              throw new DeploymentException( message );
          }
          if( null == className )
          {
              final String message = REZ.getString( "typedef.no-classname.error" );
              throw new DeploymentException( message );
          }
  
          // Add to type factory
          final DefaultTypeFactory factory = getFactory( roleName );
          factory.addNameClassMapping( typeName, className );
  
          // Deploy
          m_typeDeployer.deployType( typeDef, factory );
  
          if( getLogger().isDebugEnabled() )
          {
              final String message =
                  REZ.getString( "register-type.notice", roleName, typeName );
              getLogger().debug( message );
          }
      }
  
      /**
       * Builds descriptors.
       */
      private ArrayList buildDescriptors( final ArrayList urls,
                                          final DescriptorBuilder builder,
                                          final XMLReader parser,
                                          final SAXConfigurationHandler handler )
          throws Exception
      {
          final ArrayList descriptors = new ArrayList();
          final int size = urls.size();
          for( int i = 0; i < size; i++ )
          {
              final String url = (String)urls.get( i );
  
              // Parse the file
              parser.parse( url );
              final TypelibDescriptor descriptor =
                  builder.createDescriptor( handler.getConfiguration(), url );
              descriptors.add( descriptor );
          }
  
          return descriptors;
      }
  
      /**
       * Locates all resources of a particular name.
       */
      private ArrayList locateResources( final String resource, final URL jarUrl )
          throws Exception
      {
          final ArrayList urls = new ArrayList();
          if( null != jarUrl )
          {
              final String systemID = "jar:" + jarUrl + "!/" + resource;
              try
              {
                  // Probe the resource
                  final URL url = new URL( systemID );
                  url.openStream().close();
  
                  // Add to the list
                  urls.add( systemID );
              }
              catch( FileNotFoundException e )
              {
                  // Ignore
              }
          }
          else
          {
              final Enumeration enum = m_classLoader.getResources( resource );
              while( enum.hasMoreElements() )
              {
                  urls.add( enum.nextElement().toString() );
              }
          }
  
          return urls;
      }
  
      /**
       * Deploys the roles from a role descriptor.
       */
      private void deployRoles( final RoleDescriptor descriptor )
          throws DeploymentException
      {
          try
          {
              if( getLogger().isDebugEnabled() )
              {
                  final String message =
                      REZ.getString( "url-deploy-roles.notice", descriptor.getUrl() );
                  getLogger().debug( message );
              }
  
              final RoleDefinition[] definitions = descriptor.getDefinitions();
              for( int i = 0; i < definitions.length; i++ )
              {
                  final RoleDefinition definition = definitions[ i ];
                  deployRole( definition );
              }
          }
          catch( Exception e )
          {
              final String message = REZ.getString( "deploy-roles.error", descriptor.getUrl() );
              throw new DeploymentException( message, e );
          }
      }
  
      /**
       * Handles a role definition.
       */
      private void deployRole( final RoleDefinition roleDef )
          throws Exception
      {
          final String role = roleDef.getRoleName();
          final String className = roleDef.getClassName();
          final Class type = m_classLoader.loadClass( className );
          final RoleInfo roleInfo = new RoleInfo( role, type, null );
          m_roleRegistry.addRole( roleInfo );
  
          if( getLogger().isDebugEnabled() )
          {
              final String debugMessage = REZ.getString( "register-role.notice", role, className );
              getLogger().debug( debugMessage );
          }
      }
  
      /**
       * Deploys all types from a typelib descriptor.
       */
      private void deployTypes( final TypeDescriptor descriptor )
          throws DeploymentException
      {
          try
          {
              if( getLogger().isDebugEnabled() )
              {
                  final String message =
                      REZ.getString( "url-deploy-types.notice", descriptor.getUrl() );
                  getLogger().debug( message );
              }
  
              // Deploy all the types
              final TypeDefinition[] definitions = descriptor.getDefinitions();
              for( int i = 0; i < definitions.length; i++ )
              {
                  final TypeDefinition definition = definitions[ i ];
                  doDeployType( definition );
              }
          }
          catch( final Exception e )
          {
              final String message = REZ.getString( "deploy-types.error", descriptor.getUrl() );
              throw new DeploymentException( message, e );
          }
      }
  
      /**
       * Deploys all services from a typelib descriptor.
       */
      private void deployServices( final TypeDescriptor descriptor )
          throws DeploymentException
      {
  
          try
          {
              if( getLogger().isDebugEnabled() )
              {
                  final String message =
                      REZ.getString( "url-deploy-services.notice", descriptor.getUrl() );
                  getLogger().debug( message );
              }
  
              // Deploy the services
              final TypeDefinition[] definitions = descriptor.getDefinitions();
              for( int i = 0; i < definitions.length; i++ )
              {
                  final TypeDefinition definition = definitions[ i ];
                  doDeployType( definition );
              }
          }
          catch( Exception e )
          {
              final String message = REZ.getString( "deploy-services.error", descriptor.getUrl() );
              throw new DeploymentException( message, e );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/TypeDeployer.java
  
  Index: TypeDeployer.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.components.deployer;
  
  import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  import org.apache.myrmidon.interfaces.type.TypeFactory;
  
  /**
   * Deploys types of a particular role.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/25 01:41:50 $
   */
  public interface TypeDeployer
  {
      /**
       * Deploys a type.
       *
       * @param typeDefinition The type to deploy.
       * @param typeFactory The factory to use for instantiating the type.
       * @throws Exception On error.
       */
      void deployType( TypeDefinition typeDefinition, TypeFactory typeFactory )
          throws Exception;
  }
  
  
  
  1.50      +10 -7     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.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- DefaultEmbeddor.java	24 Apr 2002 01:39:27 -0000	1.49
  +++ DefaultEmbeddor.java	25 Apr 2002 01:41:50 -0000	1.50
  @@ -43,7 +43,7 @@
   import org.apache.myrmidon.interfaces.converter.ConverterRegistry;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.deployer.DeploymentException;
  -import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
  +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.interfaces.executor.ExecutionContainer;
  @@ -54,6 +54,7 @@
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
   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;
  @@ -65,7 +66,7 @@
    * Instantiate this to embed inside other applications.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.49 $ $Date: 2002/04/24 01:39:27 $
  + * @version $Revision: 1.50 $ $Date: 2002/04/25 01:41:50 $
    */
   public class DefaultEmbeddor
       extends AbstractLogEnabled
  @@ -207,7 +208,7 @@
       {
           // Deploy all type libraries found in the classpath
           final ClassLoader libClassloader = getClass().getClassLoader();
  -        final TypeDeployer typeDeployer = m_deployer.createDeployer( libClassloader );
  +        final TypeLibraryDeployer typeDeployer = m_deployer.createDeployer( libClassloader );
           typeDeployer.deployAll();
   
           // Deploy all type libraries in the lib directory
  @@ -268,9 +269,11 @@
           createComponent( TypeManager.ROLE,
                            TypeManager.class,
                            PREFIX + "type.DefaultTypeManager" );
  -        createComponent( RoleManager.ROLE,
  -                         RoleManager.class,
  -                         PREFIX + "role.DefaultRoleManager" );
  +        final Object roleManager =
  +            createComponent( RoleManager.ROLE,
  +                             RoleManager.class,
  +                             PREFIX + "role.DefaultRoleManager" );
  +        m_serviceManager.put( RoleRegistry.ROLE, roleManager );
           createComponent( AspectManager.ROLE,
                            AspectManager.class,
                            PREFIX + "aspect.DefaultAspectManager" );
  @@ -429,7 +432,7 @@
               try
               {
                   final File file = files[ i ].getCanonicalFile();
  -                final TypeDeployer typeDeployer = deployer.createDeployer( file );
  +                final TypeLibraryDeployer typeDeployer = deployer.createDeployer( file );
                   typeDeployer.deployAll();
               }
               catch( final DeploymentException de )
  
  
  
  1.13      +3 -2      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/role/DefaultRoleManager.java
  
  Index: DefaultRoleManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/role/DefaultRoleManager.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultRoleManager.java	24 Apr 2002 02:21:00 -0000	1.12
  +++ DefaultRoleManager.java	25 Apr 2002 01:41:50 -0000	1.13
  @@ -13,15 +13,16 @@
   import org.apache.myrmidon.interfaces.role.RoleException;
   import org.apache.myrmidon.interfaces.role.RoleInfo;
   import org.apache.myrmidon.interfaces.role.RoleManager;
  +import org.apache.myrmidon.interfaces.role.RoleRegistry;
   
   /**
    * Interface to manage roles and mapping to names.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version CVS $Revision: 1.12 $ $Date: 2002/04/24 02:21:00 $
  + * @version CVS $Revision: 1.13 $ $Date: 2002/04/25 01:41:50 $
    */
   public class DefaultRoleManager
  -    implements RoleManager
  +    implements RoleManager, RoleRegistry
   {
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultRoleManager.class );
  
  
  
  1.45      +3 -3      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.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- DefaultWorkspace.java	23 Apr 2002 12:41:00 -0000	1.44
  +++ DefaultWorkspace.java	25 Apr 2002 01:41:50 -0000	1.45
  @@ -22,7 +22,7 @@
   import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.deployer.DeploymentException;
  -import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
  +import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
   import org.apache.myrmidon.interfaces.executor.ExecutionContainer;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.executor.Executor;
  @@ -38,7 +38,7 @@
    * This is the default implementation of Workspace.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.44 $ $Date: 2002/04/23 12:41:00 $
  + * @version $Revision: 1.45 $ $Date: 2002/04/25 01:41:50 $
    */
   public class DefaultWorkspace
       extends AbstractLogEnabled
  @@ -170,7 +170,7 @@
   
           try
           {
  -            final TypeDeployer typeDeployer = deployer.createDeployer( file );
  +            final TypeLibraryDeployer typeDeployer = deployer.createDeployer( file );
               if( null == typeLib.getRole() )
               {
                   // Deploy everything in the typelib
  
  
  
  1.5       +9 -7      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/classloader/ClassLoaderManager.java
  
  Index: ClassLoaderManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/classloader/ClassLoaderManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ClassLoaderManager.java	3 Apr 2002 10:58:19 -0000	1.4
  +++ ClassLoaderManager.java	25 Apr 2002 01:41:50 -0000	1.5
  @@ -13,7 +13,7 @@
    * Manages a classloader hierarchy.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.4 $ $Date: 2002/04/03 10:58:19 $
  + * @version $Revision: 1.5 $ $Date: 2002/04/25 01:41:50 $
    */
   public interface ClassLoaderManager
   {
  @@ -22,11 +22,12 @@
   
       /**
        * Returns the ClassLoader for a Jar file.  The ClassLoader is created,
  -     * if necessary.  The ClassLoader's parent will include the common
  -     * ClassLoader, along with any extensions required by the Jar file.
  -     * It is guaranteed that each extension will appear at most once in the
  -     * ClassLoader hierarchy, so that classes from the extension can be
  -     * shared across the ClassLoaders returned by this method.
  +     * if necessary, and cached for future calls to this method.  The
  +     * ClassLoader's parent will include the common ClassLoader, along with
  +     * any extensions required by the Jar file.  It is guaranteed that each
  +     * extension will appear at most once in the ClassLoader hierarchy, so
  +     * that classes from the extension can be shared across the ClassLoaders
  +     * returned by this method.
        *
        * @param jar the jar file containing the classes to load
        * @return the classloader
  @@ -36,7 +37,8 @@
   
       /**
        * Creates a ClassLoader for a set of files.  See {@link #getClassLoader}
  -     * for details.
  +     * for details.  This method differs from {@link #getClassLoader} in
  +     * that a new ClassLoader is created on each call to this method.
        *
        * @param jars The Jar/zip files to create the classloader for.  Use null
        *             or an empty array to use the common classloader.
  
  
  
  1.9       +3 -3      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Deployer.java	1 Apr 2002 09:56:27 -0000	1.8
  +++ Deployer.java	25 Apr 2002 01:41:50 -0000	1.9
  @@ -15,7 +15,7 @@
    * This class deploys type libraries into a registry.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.8 $ $Date: 2002/04/01 09:56:27 $
  + * @version $Revision: 1.9 $ $Date: 2002/04/25 01:41:50 $
    */
   public interface Deployer
   {
  @@ -30,7 +30,7 @@
        * @return the deployer for this loader.
        * @exception DeploymentException if an error occurs.
        */
  -    TypeDeployer createDeployer( ClassLoader loader )
  +    TypeLibraryDeployer createDeployer( ClassLoader loader )
           throws DeploymentException;
   
       /**
  @@ -41,7 +41,7 @@
        * @return the deployer for this type library.
        * @exception DeploymentException if an error occurs.
        */
  -    TypeDeployer createDeployer( File file )
  +    TypeLibraryDeployer createDeployer( File file )
           throws DeploymentException;
   
       /**
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/TypeLibraryDeployer.java
  
  Index: TypeLibraryDeployer.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.deployer;
  
  /**
   * A deployer for a type library.  Allows individual elements from a type
   * library to be deployed.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/25 01:41:50 $
   */
  public interface TypeLibraryDeployer
  {
      /**
       * Deploys everything in the type library.
       * @throws DeploymentException
       *      If the library cannot be deployed.
       */
      void deployAll()
          throws DeploymentException;
  
      /**
       * Deploys a single type from the type library.  The type definition is
       * read from the type library descriptor.
       *
       * @param roleName
       *      The role name.
       *
       * @param typeName
       *      The type name.
       *
       * @throws DeploymentException
       *      If the type cannot be deployed.
       */
      void deployType( String roleName, String typeName )
          throws DeploymentException;
  
      /**
       * Deploys a single type from the type library.
       *
       * @param typeDef
       *      The type definition.
       *
       * @throws DeploymentException
       *      If the type cannot be deployed.
       */
      void deployType( TypeDefinition typeDef )
          throws DeploymentException;
  }
  
  
  
  1.11      +2 -9      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/role/RoleManager.java
  
  Index: RoleManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/role/RoleManager.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- RoleManager.java	24 Apr 2002 02:21:00 -0000	1.10
  +++ RoleManager.java	25 Apr 2002 01:41:50 -0000	1.11
  @@ -8,14 +8,14 @@
   package org.apache.myrmidon.interfaces.role;
   
   /**
  - * Interface to manage roles.
  + * Interface to lookup roles.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:ricardo@apache,org">Ricardo Rocha</a>
    * @author <a href="mailto:giacomo@apache,org">Giacomo Pati</a>
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version CVS $Revision: 1.10 $ $Date: 2002/04/24 02:21:00 $
  + * @version CVS $Revision: 1.11 $ $Date: 2002/04/25 01:41:50 $
    */
   public interface RoleManager
   {
  @@ -37,11 +37,4 @@
        * @return the role, or null if the role cannot be found.
        */
       RoleInfo getRole( String name );
  -
  -    /**
  -     * Adds a role definition.
  -     * @param role The RoleInfo definition of the role to add.
  -     * @throws RoleException If this role conflict with an existing role.
  -     */
  -    void addRole( RoleInfo role ) throws RoleException;
   }
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/role/RoleRegistry.java
  
  Index: RoleRegistry.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.role;
  
  /**
   * This interface is used to manage a registry of roles.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/25 01:41:50 $
   */
  public interface RoleRegistry
  {
      String ROLE = RoleRegistry.class.getName();
  
      /**
       * Adds a role definition.
       * @param role The RoleInfo definition of the role to add.
       * @throws RoleException If this role conflict with an existing role.
       */
      void addRole( RoleInfo role ) throws RoleException;
  
  }
  
  
  
  1.27      +9 -7      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java
  
  Index: AbstractComponentTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/AbstractComponentTest.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- AbstractComponentTest.java	24 Apr 2002 02:21:00 -0000	1.26
  +++ AbstractComponentTest.java	25 Apr 2002 01:41:50 -0000	1.27
  @@ -42,6 +42,7 @@
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
   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.ServiceFactory;
   import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeManager;
  @@ -50,7 +51,7 @@
    * A base class for tests for the default components.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.26 $ $Date: 2002/04/24 02:21:00 $
  + * @version $Revision: 1.27 $ $Date: 2002/04/25 01:41:50 $
    */
   public abstract class AbstractComponentTest
       extends AbstractContainerTestCase
  @@ -110,6 +111,7 @@
   
               component = createComponent( RoleManager.ROLE, DefaultRoleManager.class );
               m_serviceManager.put( RoleManager.ROLE, component );
  +            m_serviceManager.put( RoleRegistry.ROLE, component );
               components.add( component );
   
               component = createComponent( PropertyResolver.ROLE, DefaultPropertyResolver.class );
  @@ -163,10 +165,10 @@
   
               // Register some standard roles
               // Add some core roles
  -            final RoleManager roleManager = (RoleManager)getServiceManager().lookup( RoleManager.ROLE );
  -            roleManager.addRole( new RoleInfo( TestDataType.ROLE, TestDataType.class ) );
  -            roleManager.addRole( new RoleInfo( Converter.ROLE, Converter.class ) );
  -            roleManager.addRole( new RoleInfo( ServiceFactory.ROLE, ServiceFactory.class ) );
  +            final RoleRegistry roleRegistry = (RoleRegistry)getServiceManager().lookup( RoleRegistry.ROLE );
  +            roleRegistry.addRole( new RoleInfo( TestDataType.ROLE, TestDataType.class ) );
  +            roleRegistry.addRole( new RoleInfo( Converter.ROLE, Converter.class ) );
  +            roleRegistry.addRole( new RoleInfo( ServiceFactory.ROLE, ServiceFactory.class ) );
           }
   
           return m_serviceManager;
  @@ -215,8 +217,8 @@
       protected void registerRole( final RoleInfo roleInfo )
           throws Exception
       {
  -        RoleManager roleMgr = (RoleManager)getServiceManager().lookup( RoleManager.ROLE );
  -        roleMgr.addRole( roleInfo );
  +        RoleRegistry roleRegistry = (RoleRegistry)getServiceManager().lookup( RoleRegistry.ROLE );
  +        roleRegistry.addRole( roleInfo );
       }
   
       /**
  
  
  
  1.4       +4 -4      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultDeployerTestCase.java	11 Apr 2002 12:58:59 -0000	1.3
  +++ DefaultDeployerTestCase.java	25 Apr 2002 01:41:50 -0000	1.4
  @@ -16,7 +16,7 @@
   import org.apache.myrmidon.interfaces.deployer.ConverterDefinition;
   import org.apache.myrmidon.interfaces.deployer.Deployer;
   import org.apache.myrmidon.interfaces.deployer.TypeDefinition;
  -import org.apache.myrmidon.interfaces.deployer.TypeDeployer;
  +import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
   import org.apache.myrmidon.interfaces.type.TypeException;
   import org.apache.myrmidon.interfaces.type.TypeFactory;
   
  @@ -80,7 +80,7 @@
           final TypeDefinition typeDef = new TypeDefinition( typeName, DATA_TYPE_ROLE, classname );
   
           final ClassLoader classLoader = getClass().getClassLoader();
  -        final TypeDeployer typeDeployer = m_deployer.createDeployer( classLoader );
  +        final TypeLibraryDeployer typeDeployer = m_deployer.createDeployer( classLoader );
   
           // Make sure the test types have not been deployed
           assertTypesNotRegistered();
  @@ -108,7 +108,7 @@
               new ConverterDefinition( classname, source, destClass );
   
           final ClassLoader classLoader = getClass().getClassLoader();
  -        final TypeDeployer typeDeployer = m_deployer.createDeployer( classLoader );
  +        final TypeLibraryDeployer typeDeployer = m_deployer.createDeployer( classLoader );
   
           // Make sure the test types have not been deployed
           assertTypesNotRegistered();
  @@ -127,7 +127,7 @@
       public void testLibDescriptor() throws Exception
       {
           final File typelib = getTestResource( "test.atl" );
  -        final TypeDeployer typeDeployer = m_deployer.createDeployer( typelib );
  +        final TypeLibraryDeployer typeDeployer = m_deployer.createDeployer( typelib );
   
           // Make sure the test types have not been deployed
           assertTypesNotRegistered();
  
  
  
  1.4       +3 -3      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/role/test/DefaultRoleManagerTestCase.java
  
  Index: DefaultRoleManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/role/test/DefaultRoleManagerTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultRoleManagerTestCase.java	24 Apr 2002 02:21:01 -0000	1.3
  +++ DefaultRoleManagerTestCase.java	25 Apr 2002 01:41:50 -0000	1.4
  @@ -19,14 +19,14 @@
    * Test cases for the DefaultRoleManager.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.3 $ $Date: 2002/04/24 02:21:01 $
  + * @version $Revision: 1.4 $ $Date: 2002/04/25 01:41:50 $
    */
   public class DefaultRoleManagerTestCase
       extends AbstractContainerTestCase
   {
       private final static Resources REZ = getResourcesForTested( DefaultRoleManagerTestCase.class );
   
  -    private RoleManager m_roleManager;
  +    private DefaultRoleManager m_roleManager;
   
       public DefaultRoleManagerTestCase( String name )
       {
  @@ -99,7 +99,7 @@
           m_roleManager.addRole( origRole );
   
           // Override role
  -        final RoleManager roleManager = new DefaultRoleManager( m_roleManager );
  +        final DefaultRoleManager roleManager = new DefaultRoleManager( m_roleManager );
           final RoleInfo overrideNameRole = new RoleInfo( roleName );
           roleManager.addRole( overrideNameRole );
           final RoleInfo overrideTypeRole = new RoleInfo( "another-role", roleType );
  
  
  
  1.4       +4 -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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InstantiatingServiceManagerTestCase.java	24 Apr 2002 02:21:01 -0000	1.3
  +++ InstantiatingServiceManagerTestCase.java	25 Apr 2002 01:41:50 -0000	1.4
  @@ -14,7 +14,7 @@
   import org.apache.myrmidon.components.AbstractComponentTest;
   import org.apache.myrmidon.components.service.InstantiatingServiceManager;
   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.ServiceFactory;
   import org.apache.myrmidon.interfaces.type.DefaultTypeFactory;
   import org.apache.myrmidon.interfaces.type.TypeManager;
  @@ -23,7 +23,7 @@
    * Test cases for the default service manager.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.3 $ $Date: 2002/04/24 02:21:01 $
  + * @version $Revision: 1.4 $ $Date: 2002/04/25 01:41:50 $
    */
   public class InstantiatingServiceManagerTestCase
       extends AbstractComponentTest
  @@ -142,8 +142,8 @@
           throws Exception
       {
           // TODO - add stuff to TypeDeployer to do this instead
  -        final RoleManager roleManager = (RoleManager)getServiceManager().lookup( RoleManager.ROLE );
  -        roleManager.addRole( new RoleInfo( serviceRoleName, serviceType ) );
  +        final RoleRegistry roleRegistry = (RoleRegistry)getServiceManager().lookup( RoleRegistry.ROLE );
  +        roleRegistry.addRole( new RoleInfo( serviceRoleName, serviceType ) );
           final DefaultTypeFactory typeFactory = new DefaultTypeFactory( getClass().getClassLoader() );
           typeFactory.addNameClassMapping( serviceRoleName, factoryClass.getName() );
           final TypeManager typeManager = (TypeManager)getServiceManager().lookup( TypeManager.ROLE );
  
  
  
  1.2       +3 -3      jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/AbstractTypeDef.java
  
  Index: AbstractTypeDef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/AbstractTypeDef.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractTypeDef.java	14 Apr 2002 09:30:13 -0000	1.1
  +++ AbstractTypeDef.java	25 Apr 2002 01:41:50 -0000	1.2
  @@ -14,7 +14,7 @@
   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.deployer.TypeDeployer;
  +import org.apache.myrmidon.interfaces.deployer.TypeLibraryDeployer;
   
   /**
    * Abstract task to extend to define a type.
  @@ -22,7 +22,7 @@
    * TODO: Make this support classpath sub-element in future
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/14 09:30:13 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/25 01:41:50 $
    */
   public abstract class AbstractTypeDef
       extends AbstractContainerTask
  @@ -76,7 +76,7 @@
           {
               // Locate the deployer, and use it to deploy the type
               final Deployer deployer = (Deployer)getService( Deployer.class );
  -            final TypeDeployer typeDeployer = deployer.createDeployer( m_lib );
  +            final TypeLibraryDeployer typeDeployer = deployer.createDeployer( m_lib );
               final TypeDefinition typeDef = createTypeDefinition();
               typeDeployer.deployType( typeDef );
           }
  
  
  

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