ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer DescriptorBuilder.java Resources.properties RoleDescriptorBuilder.java ServiceDescriptorBuilder.java TypeDescriptorBuilder.java
Date Sun, 21 Apr 2002 02:06:26 GMT
donaldp     02/04/20 19:06:25

  Modified:    container/src/java/org/apache/myrmidon/components/deployer
                        DescriptorBuilder.java Resources.properties
                        RoleDescriptorBuilder.java
                        ServiceDescriptorBuilder.java
                        TypeDescriptorBuilder.java
  Log:
  Make sure you can not have multiple "types" elements in descriptors.
  
  Revision  Changes    Path
  1.2       +3 -3      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DescriptorBuilder.java
  
  Index: DescriptorBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/DescriptorBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DescriptorBuilder.java	12 Feb 2002 10:40:08 -0000	1.1
  +++ DescriptorBuilder.java	21 Apr 2002 02:06:25 -0000	1.2
  @@ -7,21 +7,21 @@
    */
   package org.apache.myrmidon.components.deployer;
   
  -import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.myrmidon.interfaces.deployer.DeploymentException;
  +import org.apache.avalon.framework.configuration.Configuration;
   
   /**
    * Builds a descriptor.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.1 $ $Date: 2002/02/12 10:40:08 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/21 02:06:25 $
    */
   interface DescriptorBuilder
   {
       /**
        * Builds a descriptor from a set of configuration.
        */
  -    TypelibDescriptor createDescriptor( Configuration config,
  +    TypelibDescriptor createDescriptor( Configuration model,
                                           String descriptorUrl )
           throws DeploymentException;
   }
  
  
  
  1.12      +1 -0      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Resources.properties	11 Mar 2002 06:02:22 -0000	1.11
  +++ Resources.properties	21 Apr 2002 02:06:25 -0000	1.12
  @@ -22,6 +22,7 @@
   build-role-descriptor.error=Could not build role descriptor from "{0}".
   type-descriptor-version.error=Type library descriptor version {0} is incompatible with
current version {1}.
   build-type-descriptor.error=Could not build type library descriptor from "{0}".
  +multi-types-element.error=Library descriptor "{0}" contains multiple top-level <types/>
elements.
   service-descriptor-version.error=Service descriptor version {0} is incompatible with current
version {1}.
   build-service-descriptor.error=Could not build service descriptor from "{0}".
   
  
  
  
  1.5       +7 -6      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/RoleDescriptorBuilder.java
  
  Index: RoleDescriptorBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/RoleDescriptorBuilder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RoleDescriptorBuilder.java	1 Apr 2002 09:56:26 -0000	1.4
  +++ RoleDescriptorBuilder.java	21 Apr 2002 02:06:25 -0000	1.5
  @@ -17,7 +17,7 @@
    * Builds typelib role descriptors.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.4 $ $Date: 2002/04/01 09:56:26 $
  + * @version $Revision: 1.5 $ $Date: 2002/04/21 02:06:25 $
    */
   class RoleDescriptorBuilder
       implements DescriptorBuilder
  @@ -30,14 +30,14 @@
       /**
        * Builds a descriptor from a set of configuration.
        */
  -    public TypelibDescriptor createDescriptor( final Configuration config,
  +    public TypelibDescriptor createDescriptor( final Configuration model,
                                                  final String url )
           throws DeploymentException
       {
           try
           {
               // Check version
  -            final String versionString = config.getAttribute( "version" );
  +            final String versionString = model.getAttribute( "version" );
               final Version version = Version.getVersion( versionString );
               if( !ROLE_DESCRIPTOR_VERSION.complies( version ) )
               {
  @@ -50,11 +50,12 @@
               final RoleDescriptor descriptor = new RoleDescriptor( url );
   
               // Extract each of the role elements
  -            final Configuration[] types = config.getChildren( "role" );
  +            final Configuration[] types = model.getChildren( "role" );
               for( int i = 0; i < types.length; i++ )
               {
  -                final String name = types[ i ].getAttribute( "shorthand" );
  -                final String role = types[ i ].getAttribute( "name" );
  +                final Configuration type = types[ i ];
  +                final String name = type.getAttribute( "shorthand" );
  +                final String role = type.getAttribute( "name" );
                   final RoleDefinition roleDef = new RoleDefinition( role, name );
                   descriptor.addDefinition( roleDef );
               }
  
  
  
  1.6       +5 -5      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ServiceDescriptorBuilder.java	1 Apr 2002 09:56:26 -0000	1.5
  +++ ServiceDescriptorBuilder.java	21 Apr 2002 02:06:25 -0000	1.6
  @@ -17,7 +17,7 @@
    * Builds typelib service descriptors.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.5 $ $Date: 2002/04/01 09:56:26 $
  + * @version $Revision: 1.6 $ $Date: 2002/04/21 02:06:25 $
    */
   class ServiceDescriptorBuilder
       implements DescriptorBuilder
  @@ -30,14 +30,14 @@
       /**
        * Builds a descriptor from a set of configuration.
        */
  -    public TypelibDescriptor createDescriptor( final Configuration config,
  +    public TypelibDescriptor createDescriptor( final Configuration model,
                                                  final String url )
           throws DeploymentException
       {
           try
           {
               // Check version
  -            final String versionString = config.getAttribute( "version" );
  +            final String versionString = model.getAttribute( "version" );
               final Version version = Version.getVersion( versionString );
               if( !SERVICE_DESCRIPTOR_VERSION.complies( version ) )
               {
  @@ -50,14 +50,14 @@
               final ServiceDescriptor descriptor = new ServiceDescriptor( url );
   
               // Add the service definitions
  -            final Configuration[] elements = config.getChildren();
  +            final Configuration[] elements = model.getChildren();
               for( int i = 0; i < elements.length; i++ )
               {
                   final Configuration element = elements[ i ];
                   final String roleShorthand = element.getName();
                   final String factoryClassName = element.getAttribute( "factory" );
                   final ServiceDefinition definition =
  -                    new ServiceDefinition( roleShorthand, factoryClassName, config );
  +                    new ServiceDefinition( roleShorthand, factoryClassName, model );
                   descriptor.addDefinition( definition );
               }
   
  
  
  
  1.6       +29 -16    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/TypeDescriptorBuilder.java
  
  Index: TypeDescriptorBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/deployer/TypeDescriptorBuilder.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TypeDescriptorBuilder.java	1 Apr 2002 09:56:26 -0000	1.5
  +++ TypeDescriptorBuilder.java	21 Apr 2002 02:06:25 -0000	1.6
  @@ -20,7 +20,7 @@
    * Builds typelib type descriptors.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.5 $ $Date: 2002/04/01 09:56:26 $
  + * @version $Revision: 1.6 $ $Date: 2002/04/21 02:06:25 $
    */
   class TypeDescriptorBuilder
       implements DescriptorBuilder
  @@ -33,14 +33,14 @@
       /**
        * Builds a descriptor from a set of configuration.
        */
  -    public TypelibDescriptor createDescriptor( final Configuration config,
  +    public TypelibDescriptor createDescriptor( final Configuration model,
                                                  final String url )
           throws DeploymentException
       {
           try
           {
               // Check version
  -            final String versionString = config.getAttribute( "version" );
  +            final String versionString = model.getAttribute( "version" );
               final Version version = Version.getVersion( versionString );
               if( !TYPE_DESCRIPTOR_VERSION.complies( version ) )
               {
  @@ -53,15 +53,28 @@
               final TypeDescriptor descriptor = new TypeDescriptor( url );
   
               // Extract each of the types elements
  -            final Configuration[] typeEntries = config.getChild( "types" ).getChildren();
  -            for( int i = 0; i < typeEntries.length; i++ )
  +            final Configuration[] children = model.getChildren( "types" );
  +            if( 0 == children.length )
               {
  -                final Configuration typeEntry = typeEntries[ i ];
  -                final TypeDefinition typeDef = createTypeDefinition( typeEntry );
  -                descriptor.addDefinition( typeDef );
  +                return descriptor;
               }
  +            else if( 1 != children.length )
  +            {
  +                final String message = REZ.getString( "multi-types-element.error", url
);
  +                throw new DeploymentException( message );
  +            }
  +            else
  +            {
  +                final Configuration[] typeEntries = children[ 0 ].getChildren();
  +                for( int i = 0; i < typeEntries.length; i++ )
  +                {
  +                    final Configuration typeEntry = typeEntries[ i ];
  +                    final TypeDefinition typeDef = createTypeDefinition( typeEntry );
  +                    descriptor.addDefinition( typeDef );
  +                }
   
  -            return descriptor;
  +                return descriptor;
  +            }
           }
           catch( Exception e )
           {
  @@ -73,23 +86,23 @@
       /**
        * Creates a type definition.
        */
  -    private TypeDefinition createTypeDefinition( final Configuration configuration )
  +    private TypeDefinition createTypeDefinition( final Configuration element )
           throws ConfigurationException
       {
  -        final String roleShorthand = configuration.getName();
  +        final String roleShorthand = element.getName();
           if( roleShorthand.equals( "converter" ) )
           {
               // A converter definition
  -            final String className = configuration.getAttribute( "classname" );
  -            final String source = configuration.getAttribute( "source" );
  -            final String destination = configuration.getAttribute( "destination" );
  +            final String className = element.getAttribute( "classname" );
  +            final String source = element.getAttribute( "source" );
  +            final String destination = element.getAttribute( "destination" );
               return new ConverterDefinition( className, source, destination );
           }
           else
           {
               // A type definition
  -            final String typeName = configuration.getAttribute( "name" );
  -            final String className = configuration.getAttribute( "classname" );
  +            final String typeName = element.getAttribute( "name" );
  +            final String className = element.getAttribute( "classname" );
               return new TypeDefinition( typeName, roleShorthand, className );
           }
       }
  
  
  

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