ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer CompoundTypeDeployer.java DefaultDeployer.java RoleDeployer.java
Date Mon, 27 May 2002 12:59:36 GMT
adammurdoch    02/05/27 05:59:36

  Modified:    container/src/java/org/apache/myrmidon/components/deployer
                        CompoundTypeDeployer.java DefaultDeployer.java
  Removed:     container/src/java/org/apache/myrmidon/components/deployer
                        RoleDeployer.java
  Log:
  Create custom deployers as types are registered, rather than as roles
  are registered.  This means that custom deployers are now created
  for every execution frame that needs them.
  
  Revision  Changes    Path
  1.7       +54 -5     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/CompoundTypeDeployer.java
  
  Index: CompoundTypeDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/CompoundTypeDeployer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CompoundTypeDeployer.java	23 May 2002 09:36:36 -0000	1.6
  +++ CompoundTypeDeployer.java	27 May 2002 12:59:36 -0000	1.7
  @@ -11,14 +11,20 @@
   import java.util.Map;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.avalon.framework.container.ContainerUtil;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.myrmidon.interfaces.ComponentException;
   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;
   
   /**
    * A type deployer that delegates to a type deployer per role.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.6 $ $Date: 2002/05/23 09:36:36 $
  + * @version $Revision: 1.7 $ $Date: 2002/05/27 12:59:36 $
    */
   class CompoundTypeDeployer
       implements TypeDeployer
  @@ -28,17 +34,26 @@
   
       private final Map m_deployers = new HashMap();
       private final TypeDeployer m_defaultDeployer;
  +    private final ServiceManager m_serviceManager;
  +    private final RoleManager m_roleManager;
   
  -    public CompoundTypeDeployer( final TypeDeployer defaultDeployer )
  +    public CompoundTypeDeployer( final TypeDeployer defaultDeployer,
  +                                 final ServiceManager serviceManager )
  +        throws ServiceException
       {
           m_defaultDeployer = defaultDeployer;
  +        ContainerUtil.service( m_defaultDeployer, serviceManager );
  +        m_serviceManager = serviceManager;
  +        m_roleManager = (RoleManager)serviceManager.lookup( RoleManager.ROLE );
       }
   
       /**
        * Adds a deployer for a role.
        */
       public void addDeployer( final String role, final TypeDeployer deployer )
  +        throws ServiceException
       {
  +        ContainerUtil.service( deployer, m_serviceManager );
           m_deployers.put( role, deployer );
       }
   
  @@ -65,11 +80,45 @@
   
           // Use the deployer for the type's role, if any.  Otherwise use the
           // default deployer
  -        TypeDeployer deployer = (TypeDeployer)m_deployers.get( typeDefinition.getRole()
);
  +        TypeDeployer deployer = findDeployer( roleName );
  +        deployer.deployType( namespace, typeDefinition );
  +    }
  +
  +    /**
  +     * Locates the deployer for a role.
  +     */
  +    private TypeDeployer findDeployer( final String roleName )
  +        throws Exception
  +    {
  +        TypeDeployer deployer = (TypeDeployer)m_deployers.get( roleName );
           if( deployer == null )
           {
  -            deployer = m_defaultDeployer;
  +            // Lookup the role
  +            final RoleInfo role = m_roleManager.getRole( roleName );
  +
  +            // Instantiate the custom type deployer for this role
  +            final String typeDeployerClassName = (String)role.getAttributes().get( RoleInfo.ATTRIBUTE_CUSTOM_TYPE_DEPLOYER
);
  +            if( typeDeployerClassName != null )
  +            {
  +                try
  +                {
  +                    final Class typeDeployerClass = role.getImplementationClass().getClassLoader().loadClass(
typeDeployerClassName );
  +                    deployer = (TypeDeployer)typeDeployerClass.newInstance();
  +                    ContainerUtil.service( deployer, m_serviceManager );
  +                }
  +                catch( final Exception e )
  +                {
  +                    final String message = REZ.getString( "create-type-deployer.error",
roleName );
  +                    throw new ComponentException( message, e );
  +                }
  +            }
  +            else
  +            {
  +                deployer = m_defaultDeployer;
  +            }
  +            m_deployers.put( roleName, deployer );
           }
  -        deployer.deployType( namespace, typeDefinition );
  +
  +        return deployer;
       }
   }
  
  
  
  1.46      +6 -10     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.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- DefaultDeployer.java	23 May 2002 09:36:36 -0000	1.45
  +++ DefaultDeployer.java	27 May 2002 12:59:36 -0000	1.46
  @@ -29,7 +29,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.45 $ $Date: 2002/05/23 09:36:36 $
  + * @version $Revision: 1.46 $ $Date: 2002/05/27 12:59:36 $
    */
   public class DefaultDeployer
       extends AbstractLogEnabled
  @@ -39,7 +39,7 @@
           ResourceManager.getPackageResources( DefaultDeployer.class );
   
       // The components used to deploy
  -    private RoleRegistry m_roleDeployer;
  +    private RoleRegistry m_roleRegistry;
       private CompoundTypeDeployer m_typeDeployer;
   
       /**
  @@ -51,18 +51,14 @@
       public void service( final ServiceManager serviceManager )
           throws ServiceException
       {
  +        m_roleRegistry = (RoleRegistry)serviceManager.lookup( RoleRegistry.ROLE );
  +
           // Assemble the type deployer
           final DefaultTypeDeployer defaultDeployer = new DefaultTypeDeployer();
  -        ContainerUtil.service( defaultDeployer, serviceManager );
  -
  +        m_typeDeployer = new CompoundTypeDeployer( defaultDeployer, serviceManager );
           final ConverterTypeDeployer converterDeployer = new ConverterTypeDeployer();
  -        ContainerUtil.service( converterDeployer, serviceManager );
  -        m_typeDeployer = new CompoundTypeDeployer( defaultDeployer );
           m_typeDeployer.addDeployer( Converter.ROLE, converterDeployer );
   
  -        // Assemble the role deployer
  -        final RoleRegistry roleRegistry = (RoleRegistry)serviceManager.lookup( RoleRegistry.ROLE
);
  -        m_roleDeployer = new RoleDeployer( roleRegistry, m_typeDeployer, serviceManager
);
       }
   
       /**
  @@ -84,7 +80,7 @@
           try
           {
               DefaultTypeLibraryDeployer deployment =
  -                new DefaultTypeLibraryDeployer( m_roleDeployer,
  +                new DefaultTypeLibraryDeployer( m_roleRegistry,
                                                   m_typeDeployer,
                                                   namespace,
                                                   library.getClassLoader() );
  
  
  

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