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/file FileListUtil.java
Date Thu, 09 May 2002 07:54:32 GMT
adammurdoch    02/05/09 00:54:32

  Modified:    antlib/src/java/org/apache/antlib/project TypeLibTask.java
               antlib/src/java/org/apache/antlib/runtime Import.java
               container/src/java/org/apache/myrmidon/components/deployer
                        DefaultDeployer.java
                        DefaultTypeLibraryDeployer.java
               container/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java
               container/src/java/org/apache/myrmidon/components/library
                        DefaultLibraryManager.java
                        DefaultTypeLibraryManager.java
               container/src/java/org/apache/myrmidon/interfaces/deployer
                        Deployer.java TypeLibraryDeployer.java
               container/src/java/org/apache/myrmidon/interfaces/library
                        LibraryManager.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/library/test
                        DefaultLibraryManagerTestCase.java
               framework/src/java/org/apache/myrmidon/framework
                        AbstractTypeDef.java
               framework/src/java/org/apache/myrmidon/framework/file
                        FileListUtil.java
  Log:
  Get library names working:
  
  * Implemented Library.getName() for antlibs.  The file basename is being used
    for the library name, for now.
  
  * <typelib> uses the library name as the namespace, if none is provided.
  
  * DefaultEmbeddor uses the library name as the namespace for each core antlib.
  
  * Moved namespace parameter from TypeLibraryDeployer methods to
    Deployer.createDeployer().
  
  * DefaultDeployer no longer caches TypeLibDeployers.
  
  * Fixed the container tests (except DefaultLibraryManagerTestCase).
  
  Revision  Changes    Path
  1.4       +7 -3      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/TypeLibTask.java
  
  Index: TypeLibTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/TypeLibTask.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TypeLibTask.java	8 May 2002 04:10:26 -0000	1.3
  +++ TypeLibTask.java	9 May 2002 07:54:31 -0000	1.4
  @@ -104,18 +104,22 @@
           {
               final TypeLibraryManager libraryManager = (TypeLibraryManager)getService( TypeLibraryManager.class
);
               final Library library = libraryManager.getTypeLibrary( m_library );
  +            if( m_namespace == null )
  +            {
  +                m_namespace = library.getName();
  +            }
   
               final Deployer deployer = (Deployer)getService( Deployer.class );
  -            final TypeLibraryDeployer typeDeployer = deployer.createDeployer( library );
  +            final TypeLibraryDeployer typeDeployer = deployer.createDeployer( library,
m_namespace );
               if( null == m_role )
               {
                   // Deploy everything in the typelib
  -                typeDeployer.deployAll( m_namespace );
  +                typeDeployer.deployAll();
               }
               else
               {
                   // Deploy the specified type
  -                typeDeployer.deployType( m_role, m_namespace, m_name );
  +                typeDeployer.deployType( m_role, m_name );
               }
           }
           catch( final Exception de )
  
  
  
  1.5       +3 -3      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Import.java	8 May 2002 04:10:26 -0000	1.4
  +++ Import.java	9 May 2002 07:54:31 -0000	1.5
  @@ -54,10 +54,10 @@
           try
           {
               final LibraryManager libraryManager = (LibraryManager)getService( LibraryManager.class
);
  -            final Library library = libraryManager.createLibrary( new File[] { m_lib }
);
  +            final Library library = libraryManager.createLibrary( null, new File[] { m_lib
} );
               final Deployer deployer = (Deployer)getService( Deployer.class );
  -            final TypeLibraryDeployer typeDeployer = deployer.createDeployer( library );
  -            typeDeployer.deployAll( m_namespace );
  +            final TypeLibraryDeployer typeDeployer = deployer.createDeployer( library,
m_namespace );
  +            typeDeployer.deployAll();
           }
           catch( final Exception e )
           {
  
  
  
  1.41      +10 -16    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.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- DefaultDeployer.java	3 May 2002 06:56:10 -0000	1.40
  +++ DefaultDeployer.java	9 May 2002 07:54:31 -0000	1.41
  @@ -7,8 +7,6 @@
    */
   package org.apache.myrmidon.components.deployer;
   
  -import java.util.HashMap;
  -import java.util.Map;
   import org.apache.aut.converter.Converter;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  @@ -28,7 +26,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.40 $ $Date: 2002/05/03 06:56:10 $
  + * @version $Revision: 1.41 $ $Date: 2002/05/09 07:54:31 $
    */
   public class DefaultDeployer
       extends AbstractLogEnabled
  @@ -41,9 +39,6 @@
       private RoleRegistry m_roleDeployer;
       private CompoundTypeDeployer m_typeDeployer;
   
  -    /** Map from ClassLoader to the deployer for that class loader. */
  -    private final Map m_classLoaderDeployers = new HashMap();
  -
       /**
        * Retrieve relevent services needed to deploy.
        *
  @@ -82,20 +77,19 @@
        * Returns the deployer for a library, creating the deployer if
        * necessary.
        */
  -    public TypeLibraryDeployer createDeployer( final Library library )
  +    public TypeLibraryDeployer createDeployer( final Library library,
  +                                               final String namespace )
           throws DeploymentException
       {
           try
           {
  -            // Locate cached deployer, creating it if necessary
  -            DefaultTypeLibraryDeployer deployment = (DefaultTypeLibraryDeployer)m_classLoaderDeployers.get(
library );
  -            if( deployment == null )
  -            {
  -                deployment = new DefaultTypeLibraryDeployer( m_roleDeployer, m_typeDeployer,
library.getClassLoader() );
  -                setupLogger( deployment );
  -                deployment.loadDescriptors( library.getClassPath() );
  -                m_classLoaderDeployers.put( library, deployment );
  -            }
  +            DefaultTypeLibraryDeployer deployment =
  +                new DefaultTypeLibraryDeployer( m_roleDeployer,
  +                                                m_typeDeployer,
  +                                                namespace,
  +                                                library.getClassLoader() );
  +            setupLogger( deployment );
  +            deployment.loadDescriptors( library.getClassPath() );
   
               return deployment;
           }
  
  
  
  1.6       +14 -28    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultTypeLibraryDeployer.java
  
  Index: DefaultTypeLibraryDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DefaultTypeLibraryDeployer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultTypeLibraryDeployer.java	8 May 2002 04:10:26 -0000	1.5
  +++ DefaultTypeLibraryDeployer.java	9 May 2002 07:54:31 -0000	1.6
  @@ -32,7 +32,9 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.5 $ $Date: 2002/05/08 04:10:26 $
  + * @version $Revision: 1.6 $ $Date: 2002/05/09 07:54:31 $
  + *
  + * @todo Keep track of which types have been deployed, and don't redeploy them.
    */
   class DefaultTypeLibraryDeployer
       extends AbstractLogEnabled
  @@ -45,6 +47,7 @@
       private static final String ROLE_DESCRIPTOR_NAME = "META-INF/ant-roles.xml";
   
       private final TypeDeployer m_typeDeployer;
  +    private final String m_namespace;
       private final ClassLoader m_classLoader;
       private TypeDescriptor[] m_descriptors;
   
  @@ -52,16 +55,18 @@
       private DescriptorBuilder m_roleBuilder = new RoleDescriptorBuilder();
       private DescriptorBuilder m_typeBuilder = new TypeDescriptorBuilder();
   
  -    /** Map from role Class -> DefaultTypeFactory for that role. */
  +    /** Map from role name -> DefaultTypeFactory for that role. */
       private Map m_factories = new HashMap();
       private final RoleRegistry m_roleRegistry;
   
       public DefaultTypeLibraryDeployer( final RoleRegistry roleRegistry,
                                          final TypeDeployer typeDeployer,
  +                                       final String namespace,
                                          final ClassLoader classLoader )
       {
           m_roleRegistry = roleRegistry;
           m_typeDeployer = typeDeployer;
  +        m_namespace = namespace;
           m_classLoader = classLoader;
       }
   
  @@ -137,17 +142,11 @@
       public void deployAll()
           throws DeploymentException
       {
  -        deployAll( null );
  -    }
  -
  -    public void deployAll( String namespace )
  -        throws DeploymentException
  -    {
           // Deploy types
           for( int i = 0; i < m_descriptors.length; i++ )
           {
               TypeDescriptor descriptor = m_descriptors[ i ];
  -            deployTypes( namespace, descriptor );
  +            deployTypes( descriptor );
           }
       }
   
  @@ -157,12 +156,6 @@
       public void deployType( final String roleName, final String typeName )
           throws DeploymentException
       {
  -        deployType( roleName, null, typeName );
  -    }
  -
  -    public void deployType( String roleName, String namespace, String typeName )
  -        throws DeploymentException
  -    {
           try
           {
               // Locate the definition for the type
  @@ -179,7 +172,7 @@
                           // Found the definition - deploy it.  Note that we
                           // keep looking for matching types, and let the deployer
                           // deal with duplicates
  -                        doDeployType( namespace, definition );
  +                        doDeployType( definition );
                       }
                   }
               }
  @@ -197,15 +190,9 @@
       public void deployType( final TypeDefinition typeDef )
           throws DeploymentException
       {
  -        deployType( null, typeDef );
  -    }
  -
  -    public void deployType( String namespace, TypeDefinition typeDef )
  -        throws DeploymentException
  -    {
           try
           {
  -            doDeployType( namespace, typeDef );
  +            doDeployType( typeDef );
           }
           catch( Exception e )
           {
  @@ -218,7 +205,7 @@
       /**
        * Deploys a type.
        */
  -    private void doDeployType( final String namespace, final TypeDefinition typeDef )
  +    private void doDeployType( final TypeDefinition typeDef )
           throws Exception
       {
           // Validate the type definition
  @@ -246,7 +233,7 @@
           factory.addNameClassMapping( typeName, className );
   
           // Deploy
  -        m_typeDeployer.deployType( namespace, typeDef, factory );
  +        m_typeDeployer.deployType( m_namespace, typeDef, factory );
   
           if( getLogger().isDebugEnabled() )
           {
  @@ -371,8 +358,7 @@
       /**
        * Deploys all types from a typelib descriptor.
        */
  -    private void deployTypes( final String namespace,
  -                              final TypeDescriptor descriptor )
  +    private void deployTypes( final TypeDescriptor descriptor )
           throws DeploymentException
       {
           try
  @@ -389,7 +375,7 @@
               for( int i = 0; i < definitions.length; i++ )
               {
                   final TypeDefinition definition = definitions[ i ];
  -                doDeployType( namespace, definition );
  +                doDeployType( definition );
               }
           }
           catch( final Exception e )
  
  
  
  1.61      +5 -9      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.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- DefaultEmbeddor.java	8 May 2002 04:10:26 -0000	1.60
  +++ DefaultEmbeddor.java	9 May 2002 07:54:31 -0000	1.61
  @@ -64,7 +64,7 @@
    * Instantiate this to embed inside other applications.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.60 $ $Date: 2002/05/08 04:10:26 $
  + * @version $Revision: 1.61 $ $Date: 2002/05/09 07:54:31 $
    */
   public class DefaultEmbeddor
       extends AbstractLogEnabled
  @@ -79,9 +79,6 @@
       /** Namespace for the container types */
       private static final String CONTAINER_TYPE_NAMESPACE = "myrmidon";
   
  -    /** Namespace for the core antlibs */
  -    private static final String CORE_TYPE_NAMESPACE = "ant";
  -
       private Deployer m_deployer;
       private TypeManager m_typeManager;
       private LibraryManager m_libraryManager;
  @@ -220,17 +217,16 @@
           // Deploy all types found in the container classpath
           final ClassLoader containerClassLoader = getClass().getClassLoader();
           final Library containerLib = m_libraryManager.createLibrary( containerClassLoader
);
  -        final TypeLibraryDeployer containerTypeDeployer = m_deployer.createDeployer( containerLib
);
  -        containerTypeDeployer.deployAll( CONTAINER_TYPE_NAMESPACE );
  +        final TypeLibraryDeployer containerTypeDeployer = m_deployer.createDeployer( containerLib,
CONTAINER_TYPE_NAMESPACE );
  +        containerTypeDeployer.deployAll();
   
           // Deploy all core type libraries in the lib directory
  -        // TODO: Deploy these under library name, instead of "core"?
           final Library[] coreLibs = m_typeLibraryManager.getCoreTypeLibraries();
           for( int i = 0; i < coreLibs.length; i++ )
           {
               final Library library = coreLibs[ i ];
  -            final TypeLibraryDeployer libDeployer = m_deployer.createDeployer( library
);
  -            libDeployer.deployAll( CORE_TYPE_NAMESPACE );
  +            final TypeLibraryDeployer libDeployer = m_deployer.createDeployer( library,
library.getName() );
  +            libDeployer.deployAll();
           }
       }
   
  
  
  
  1.2       +3 -3      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/library/DefaultLibraryManager.java
  
  Index: DefaultLibraryManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/library/DefaultLibraryManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultLibraryManager.java	3 May 2002 06:56:11 -0000	1.1
  +++ DefaultLibraryManager.java	9 May 2002 07:54:32 -0000	1.2
  @@ -38,7 +38,7 @@
    * The default library manager implementation.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.1 $ $Date: 2002/05/03 06:56:11 $
  + * @version $Revision: 1.2 $ $Date: 2002/05/09 07:54:32 $
    */
   public class DefaultLibraryManager
       implements Serviceable, Contextualizable, LibraryManager
  @@ -94,7 +94,7 @@
       /**
        * Creates a library for a set of files.
        */
  -    public Library createLibrary( final File[] files )
  +    public Library createLibrary( final String name, final File[] files )
           throws Exception
       {
           try
  @@ -114,7 +114,7 @@
               final URL[] urls = toUrls( files );
               final ClassLoader classLoader = new MultiParentURLClassLoader( urls, parentClassLoaders
);
   
  -            return new DefaultLibrary( null, null, classLoader, urls );
  +            return new DefaultLibrary( name, null, classLoader, urls );
           }
           catch( final Exception e )
           {
  
  
  
  1.2       +4 -2      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/library/DefaultTypeLibraryManager.java
  
  Index: DefaultTypeLibraryManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/library/DefaultTypeLibraryManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultTypeLibraryManager.java	3 May 2002 06:56:11 -0000	1.1
  +++ DefaultTypeLibraryManager.java	9 May 2002 07:54:32 -0000	1.2
  @@ -29,7 +29,7 @@
    * The default type library manager implementation.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.1 $ $Date: 2002/05/03 06:56:11 $
  + * @version $Revision: 1.2 $ $Date: 2002/05/09 07:54:32 $
    */
   public class DefaultTypeLibraryManager
       implements TypeLibraryManager, Contextualizable, Serviceable
  @@ -137,7 +137,9 @@
               final String message = REZ.getString( "no-read.error", library );
               throw new Exception( message );
           }
  -        return m_libManager.createLibrary( new File[] { library } );
  +        final String baseName = library.getName();
  +        final String libName = baseName.substring( 0, baseName.length() - 4 );
  +        return m_libManager.createLibrary( libName, new File[] { library } );
       }
   
   }
  
  
  
  1.11      +8 -6      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Deployer.java	3 May 2002 06:56:11 -0000	1.10
  +++ Deployer.java	9 May 2002 07:54:32 -0000	1.11
  @@ -15,7 +15,8 @@
    * This class deploys type libraries into a registry.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.10 $ $Date: 2002/05/03 06:56:11 $
  + * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  + * @version $Revision: 1.11 $ $Date: 2002/05/09 07:54:32 $
    */
   public interface Deployer
   {
  @@ -23,19 +24,20 @@
       String ROLE = Deployer.class.getName();
   
       /**
  -     * Returns the deployer for a library, creating the deployer if
  -     * necessary.
  +     * Creates a deployer for a library.
        *
  -     * @param library The library.
  +     * @param library The library to deploy from.
  +     * @param namespace The namespace to deploy into.  Use null to deploy into
  +     *        the default namespace.
        * @return The deployer for this type library.
        * @exception DeploymentException if an error occurs.
        */
  -    TypeLibraryDeployer createDeployer( Library library )
  +    TypeLibraryDeployer createDeployer( Library library, String namespace )
           throws DeploymentException;
   
       /**
        * Creates a deployer which is a child of this deployer.
  -     * @param componentManager the ServiceManager for this component.
  +     * @param componentManager the ServiceManager for the child deployer to use.
        * @return a child deployer.
        * @throws ServiceException if an error occurs.
        */
  
  
  
  1.3       +3 -45     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/TypeLibraryDeployer.java
  
  Index: TypeLibraryDeployer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/deployer/TypeLibraryDeployer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeLibraryDeployer.java	8 May 2002 04:10:27 -0000	1.2
  +++ TypeLibraryDeployer.java	9 May 2002 07:54:32 -0000	1.3
  @@ -13,12 +13,13 @@
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.2 $ $Date: 2002/05/08 04:10:27 $
  + * @version $Revision: 1.3 $ $Date: 2002/05/09 07:54:32 $
    */
   public interface TypeLibraryDeployer
   {
       /**
  -     * Deploys everything in the type library, using an empty namespace.
  +     * Deploys everything in the type library.
  +     *
        * @throws DeploymentException
        *      If the library cannot be deployed.
        */
  @@ -26,15 +27,6 @@
           throws DeploymentException;
   
       /**
  -     * Deploys everything in the type library under the specified namespace.
  -     * @param namespace The namespace under which the types should be deployed.
  -     * @throws DeploymentException
  -     *      If the library cannot be deployed.
  -     */
  -    void deployAll( String namespace )
  -        throws DeploymentException;
  -
  -    /**
        * Deploys a single type from the type library.  The type definition is
        * read from the type library descriptor.
        *
  @@ -51,25 +43,6 @@
           throws DeploymentException;
   
       /**
  -     * Deploys a single type from the type library under the specified namespace.
  -     * The type definition is read from the type library descriptor.
  -     *
  -     * @param roleName
  -     *      The role name.
  -     *
  -     * @param namespace
  -     *      The namespace to deploy the type under.
  -     *
  -     * @param typeName
  -     *      The type name.
  -     *
  -     * @throws DeploymentException
  -     *      If the type cannot be deployed.
  -     */
  -    void deployType( String roleName, String namespace, String typeName )
  -        throws DeploymentException;
  -
  -    /**
        * Deploys a single type from the type library.
        *
        * @param typeDef
  @@ -80,19 +53,4 @@
        */
       void deployType( TypeDefinition typeDef )
           throws DeploymentException;
  -
  -    /**
  -      * Deploys a single type from the type library, under the specified namespace.
  -      *
  -      * @param typeDef
  -      *      The type definition.
  -      *
  -      * @param namespace
  -      *      The namespace to deploy the type under.
  -      *
  -      * @throws DeploymentException
  -      *      If the type cannot be deployed.
  -      */
  -     void deployType( String namespace, TypeDefinition typeDef )
  -         throws DeploymentException;
   }
  
  
  
  1.2       +2 -2      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/library/LibraryManager.java
  
  Index: LibraryManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/library/LibraryManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LibraryManager.java	3 May 2002 06:56:11 -0000	1.1
  +++ LibraryManager.java	9 May 2002 07:54:32 -0000	1.2
  @@ -13,7 +13,7 @@
    * Manages a set of libraries.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.1 $ $Date: 2002/05/03 06:56:11 $
  + * @version $Revision: 1.2 $ $Date: 2002/05/09 07:54:32 $
    */
   public interface LibraryManager
   {
  @@ -40,5 +40,5 @@
        * classes can be shared across the libraries created by this library
        * manager.
        */
  -    Library createLibrary( File[] files ) throws Exception;
  +    Library createLibrary( String name, File[] files ) throws Exception;
   }
  
  
  
  1.32      +6 -5      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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- AbstractComponentTest.java	3 May 2002 06:56:11 -0000	1.31
  +++ AbstractComponentTest.java	9 May 2002 07:54:32 -0000	1.32
  @@ -60,7 +60,7 @@
    * A base class for tests for the default components.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.31 $ $Date: 2002/05/03 06:56:11 $
  + * @version $Revision: 1.32 $ $Date: 2002/05/09 07:54:32 $
    */
   public abstract class AbstractComponentTest
       extends AbstractContainerTestCase
  @@ -271,10 +271,11 @@
                                         final Class destClass )
           throws Exception
       {
  -        ConverterRegistry converterRegistry = (ConverterRegistry)getServiceManager().lookup(
ConverterRegistry.ROLE );
  -        converterRegistry.registerConverter( converterClass.getName(), sourceClass.getName(),
destClass.getName() );
  +        final ConverterRegistry converterRegistry = (ConverterRegistry)getServiceManager().lookup(
ConverterRegistry.ROLE );
  +        final String converterName = converterClass.getName().replace( TypeManager.NAMESPACE_SEPARATOR,
'_' );
  +        converterRegistry.registerConverter( converterName, sourceClass.getName(), destClass.getName()
);
           DefaultTypeFactory factory = new DefaultTypeFactory( getClass().getClassLoader()
);
  -        factory.addNameClassMapping( converterClass.getName(), converterClass.getName()
);
  -        getTypeManager().registerType( Converter.ROLE, converterClass.getName(), factory
);
  +        factory.addNameClassMapping( converterName, converterClass.getName() );
  +        getTypeManager().registerType( Converter.ROLE, converterName, factory );
       }
   }
  
  
  
  1.8       +53 -40    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultDeployerTestCase.java	8 May 2002 04:10:27 -0000	1.7
  +++ DefaultDeployerTestCase.java	9 May 2002 07:54:32 -0000	1.8
  @@ -79,12 +79,12 @@
       {
           final File file = getTestResource( "test.atl" );
           final LibraryManager libraryManager = (LibraryManager)getServiceManager().lookup(
LibraryManager.ROLE );
  -        final Library library = libraryManager.createLibrary( new File[] { file } );
  -        return m_deployer.createDeployer( library );
  +        final Library library = libraryManager.createLibrary( "test", new File[] { file
} );
  +        return m_deployer.createDeployer( library, TEST_NAMESPACE );
       }
   
       /**
  -     * Tests deployment of a single type from a ClassLoader.
  +     * Tests deployment of a single type.
        */
       public void testSingleType() throws Exception
       {
  @@ -104,9 +104,7 @@
           typeDeployer.deployType( typeDef );
   
           // Check the type has been registered
  -        final TypeFactory typeFactory = getTypeManager().getFactory( TestDataType.ROLE
);
  -        final Object result = typeFactory.create( typeName );
  -        assertTrue( result instanceof TestType1 );
  +        assertTypeRegistered( TestDataType.ROLE, typeName, TestType1.class );
       }
   
       /**
  @@ -155,32 +153,6 @@
       }
   
       /**
  -     * Tests deployment of all types from a typelib descriptor under
  -     * a specified namespace.
  -     */
  -    public void testDeployUnderNamespace() throws Exception
  -    {
  -        final TypeLibraryDeployer typeDeployer = getTestDeployer();
  -
  -        // Make sure the test types have not been deployed.  Do this after
  -        // the deployer has been created
  -        assertTypesNotRegistered();
  -
  -        // Deploy all the types from the descriptor
  -        typeDeployer.deployAll( TEST_NAMESPACE );
  -
  -        // Make sure the test types can be accessed without specifying a namespace.
  -        assertTypesRegistered();
  -
  -        // Check that the Type can be accessed with a namespace qualified name.
  -        String qname = TEST_NAMESPACE + TypeManager.NAMESPACE_SEPARATOR + TEST_TYPE1_NAME;
  -        final TypeFactory typeFactory = getTypeManager().getFactory( TestDataType.ROLE
);
  -        final Object result = typeFactory.create( qname );
  -        assertTrue( result instanceof TestType1 );
  -
  -    }
  -
  -    /**
        * Ensures that the test types have not ben deployed.
        */
       private void assertTypesNotRegistered() throws Exception
  @@ -196,11 +168,20 @@
           {
               // TODO - check error message
           }
  +        try
  +        {
  +            typeFactory.create( getQualifiedName( TEST_TYPE1_NAME ) );
  +            fail();
  +        }
  +        catch( TypeException e )
  +        {
  +            // TODO - check error message
  +        }
   
           // Check the custom role implementation
  +        typeFactory = getTypeManager().getFactory( TestRole1.ROLE );
           try
           {
  -            typeFactory = getTypeManager().getFactory( TestRole1.ROLE );
               typeFactory.create( TEST_TYPE1_NAME );
               fail();
           }
  @@ -208,6 +189,15 @@
           {
               // TODO - check error message
           }
  +        try
  +        {
  +            typeFactory.create( getQualifiedName( TEST_TYPE1_NAME ) );
  +            fail();
  +        }
  +        catch( TypeException e )
  +        {
  +            // TODO - check error message
  +        }
   
           // Check the converter
           try
  @@ -222,23 +212,46 @@
       }
   
       /**
  +     * Asserts that a type has been registered correctly.
  +     */
  +    private void assertTypeRegistered( final String role,
  +                                       final String typeName,
  +                                       final Class implClass )
  +        throws Exception
  +    {
  +        // Shorthand name
  +        final TypeFactory typeFactory = getTypeManager().getFactory( role );
  +        Object result = typeFactory.create( typeName );
  +        assertTrue( implClass.isInstance( result ) );
  +
  +        // Qualified name
  +        final String qname = getQualifiedName( typeName );
  +        result = typeFactory.create( qname );
  +        assertTrue( implClass.isInstance( result ) );
  +    }
  +
  +    /**
  +     * Returns the qualified name for a type.
  +     */
  +    private String getQualifiedName( final String typeName )
  +    {
  +        return TEST_NAMESPACE + TypeManager.NAMESPACE_SEPARATOR + typeName;
  +    }
  +
  +    /**
        * Ensures the types from the test typelib descriptor have been correctly
        * deployed.
        */
       private void assertTypesRegistered() throws Exception
       {
           // Check the data-type
  -        TypeFactory typeFactory = getTypeManager().getFactory( TestDataType.ROLE );
  -        Object object = typeFactory.create( TEST_TYPE1_NAME );
  -        assertTrue( object instanceof TestType1 );
  +        assertTypeRegistered( TestDataType.ROLE, TEST_TYPE1_NAME, TestType1.class );
   
           // Check the custom role implementation
  -        typeFactory = getTypeManager().getFactory( TestRole1.ROLE );
  -        object = typeFactory.create( TEST_TYPE1_NAME );
  -        assertTrue( object instanceof TestType1 );
  +        assertTypeRegistered( TestRole1.ROLE, TEST_TYPE1_NAME, TestType1.class );
   
           // Check the converter
  -        object = m_converter.convert( TestType1.class, "some string", null );
  +        final Object object = m_converter.convert( TestType1.class, "some string", null
);
           assertTrue( object instanceof TestType1 );
       }
   }
  
  
  
  1.2       +6 -6      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/library/test/DefaultLibraryManagerTestCase.java
  
  Index: DefaultLibraryManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/library/test/DefaultLibraryManagerTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultLibraryManagerTestCase.java	3 May 2002 06:56:11 -0000	1.1
  +++ DefaultLibraryManagerTestCase.java	9 May 2002 07:54:32 -0000	1.2
  @@ -22,7 +22,7 @@
    * Test cases for the DefaultClassLoaderManager.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.1 $ $Date: 2002/05/03 06:56:11 $
  + * @version $Revision: 1.2 $ $Date: 2002/05/09 07:54:32 $
    */
   public class DefaultLibraryManagerTestCase
       extends AbstractComponentTest
  @@ -220,7 +220,7 @@
   
           // Build the classloader
           final File jarFile = getTestResource( "no-dependencies.jar" );
  -        final Library lib = m_libraryManager.createLibrary( new File[] { jarFile } );
  +        final Library lib = m_libraryManager.createLibrary( null, new File[] { jarFile
} );
           final ClassLoader classLoader = lib.getClassLoader();
   
           // Check shared classes/resources
  @@ -250,7 +250,7 @@
   
           // Build the Jar classloader
           final File jarFile = getTestResource( "one-dependency.jar" );
  -        final Library lib = m_libraryManager.createLibrary( new File[] { jarFile } );
  +        final Library lib = m_libraryManager.createLibrary( null, new File[] { jarFile
} );
           final ClassLoader classLoader = lib.getClassLoader();
   
           // Check shared classes/resources
  @@ -278,10 +278,10 @@
   
           // Build the Jar classloaders
           final File jarFile1 = getTestResource( "one-dependency.jar" );
  -        final Library lib1 = m_libraryManager.createLibrary( new File[] { jarFile1 } );
  +        final Library lib1 = m_libraryManager.createLibrary( null, new File[] { jarFile1
} );
           final ClassLoader classLoader1 = lib1.getClassLoader();
           final File jarFile2 = getTestResource( "one-dependency-2.jar" );
  -        final Library lib2 = m_libraryManager.createLibrary( new File[] { jarFile2 } );
  +        final Library lib2 = m_libraryManager.createLibrary( null, new File[] { jarFile2
} );
           final ClassLoader classLoader2 = lib2.getClassLoader();
   
           // Check extension classes/resources
  @@ -299,7 +299,7 @@
           final File jarFile = getTestResource( "ext/cycle-extension-1.jar" );
           try
           {
  -            m_libraryManager.createLibrary( new File[] { jarFile } );
  +            m_libraryManager.createLibrary( null, new File[] { jarFile } );
               fail();
           }
           catch( final Exception e )
  
  
  
  1.5       +4 -4      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractTypeDef.java	8 May 2002 04:10:27 -0000	1.4
  +++ AbstractTypeDef.java	9 May 2002 07:54:32 -0000	1.5
  @@ -25,7 +25,7 @@
    * TODO: Make this support classpath sub-element in future
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.4 $ $Date: 2002/05/08 04:10:27 $
  + * @version $Revision: 1.5 $ $Date: 2002/05/09 07:54:32 $
    */
   public abstract class AbstractTypeDef
       extends AbstractContainerTask
  @@ -83,11 +83,11 @@
           try
           {
               final LibraryManager libraryManager = (LibraryManager)getService( LibraryManager.class
);
  -            final Library library = libraryManager.createLibrary( classpath );
  +            final Library library = libraryManager.createLibrary( null, classpath );
               final Deployer deployer = (Deployer)getService( Deployer.class );
  -            final TypeLibraryDeployer typeDeployer = deployer.createDeployer( library );
  +            final TypeLibraryDeployer typeDeployer = deployer.createDeployer( library,
m_namespace );
               final TypeDefinition typeDef = createTypeDefinition();
  -            typeDeployer.deployType( m_namespace, typeDef );
  +            typeDeployer.deployType( typeDef );
           }
           catch( final Exception e )
           {
  
  
  
  1.4       +2 -2      jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/file/FileListUtil.java
  
  Index: FileListUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/file/FileListUtil.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FileListUtil.java	3 May 2002 06:56:12 -0000	1.3
  +++ FileListUtil.java	9 May 2002 07:54:32 -0000	1.4
  @@ -21,7 +21,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.3 $ $Date: 2002/05/03 06:56:12 $
  + * @version $Revision: 1.4 $ $Date: 2002/05/09 07:54:32 $
    */
   public final class FileListUtil
   {
  @@ -91,7 +91,7 @@
           final LibraryManager manager = (LibraryManager)context.getService( LibraryManager.class
);
           try
           {
  -            final Library library = manager.createLibrary( files );
  +            final Library library = manager.createLibrary( null, files );
               return library.getClassLoader();
           }
           catch( final 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