You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2002/08/16 13:48:12 UTC

cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/infobuilder BlockInfoBuilder.java

mcconnell    2002/08/16 04:48:12

  Modified:    src/java/org/apache/avalon/phoenix/tools/infobuilder
                        BlockInfoBuilder.java
  Log:
  Updated to support both the Phoenix blockinfo and the Avalon Type DTD for the xinfo file.
  
  Revision  Changes    Path
  1.21      +106 -21   jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/infobuilder/BlockInfoBuilder.java
  
  Index: BlockInfoBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/infobuilder/BlockInfoBuilder.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- BlockInfoBuilder.java	6 Aug 2002 11:57:42 -0000	1.20
  +++ BlockInfoBuilder.java	16 Aug 2002 11:48:12 -0000	1.21
  @@ -24,7 +24,8 @@
    * objects from Configuration objects. The format for Configuration object
    * is specified in the BlockInfo specification.
    *
  - * @author <a href="mailto:peter at apache.org">Peter Donald</a>
  + * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  + * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
    * @version $Revision$ $Date$
    */
   public final class BlockInfoBuilder
  @@ -51,19 +52,47 @@
               getLogger().debug( message );
           }
   
  +        final boolean flag = info.getName().equals("type");
  +
  +        if( flag )
  +        {
  +            if( info.getChild("stages", false ) != null )
  +            {
  +                final String error =
  +                 "Poenix does not support components declaring phase extension dependecies." 
  +                 + " Class: " + classname; 
  +                throw new IllegalArgumentException( error );
  +            }
  +            if( info.getChild("extensions", false ) != null )
  +            {
  +                final String error =
  +                 "Poenix does not support components declaring phase extension handlers." 
  +                 + " Class: " + classname; 
  +                throw new IllegalArgumentException( error );
  +            }
  +        }
  +
           Configuration configuration = null;
   
           configuration = info.getChild( "services" );
  -        final ServiceDescriptor[] services = buildServices( configuration );
  +        final ServiceDescriptor[] services = buildServices( configuration, flag );
   
           configuration = info.getChild( "management-access-points" );
  -        final ServiceDescriptor[] management = buildServices( configuration );
  +        final ServiceDescriptor[] management = buildServices( configuration, flag );
   
           configuration = info.getChild( "dependencies" );
  -        final DependencyDescriptor[] dependencies = buildDependencies( classname, configuration );
  +        final DependencyDescriptor[] dependencies = buildDependencies( classname, configuration, flag );
   
  -        configuration = info.getChild( "block" );
  -        final BlockDescriptor descriptor = buildBlockDescriptor( classname, configuration );
  +        if( flag )
  +        {
  +            configuration = info.getChild( "component" );
  +        }
  +        else
  +        {
  +            configuration = info.getChild( "block" );
  +        }
  +
  +        final BlockDescriptor descriptor = buildBlockDescriptor( classname, configuration, flag );
   
           if( getLogger().isDebugEnabled() )
           {
  @@ -83,11 +112,13 @@
        *
        * @param classname The classname of Block (used for logging purposes)
        * @param configuration the dependencies configuration
  +     * @param flag if TRUE build dependencies using the Avalon Type DTD
        * @return the created DependencyDescriptor
        * @throws ConfigurationException if an error occurs
        */
       private DependencyDescriptor[] buildDependencies( final String classname,
  -                                                      final Configuration configuration )
  +                                                      final Configuration configuration,
  +                                                      final boolean flag )
           throws ConfigurationException
       {
           final Configuration[] elements = configuration.getChildren( "dependency" );
  @@ -96,7 +127,7 @@
           for( int i = 0; i < elements.length; i++ )
           {
               final DependencyDescriptor dependency =
  -                buildDependency( classname, elements[ i ] );
  +                buildDependency( classname, elements[ i ], flag );
               dependencies.add( dependency );
           }
   
  @@ -109,14 +140,25 @@
        *
        * @param classname The classname of Block (used for logging purposes)
        * @param dependency the dependency configuration
  +     * @param flag if TRUE build dependency using the Avalon Type DTD
        * @return the created DependencyDescriptor
        * @throws ConfigurationException if an error occurs
        */
       private DependencyDescriptor buildDependency( final String classname,
  -                                                  final Configuration dependency )
  +                                                  final Configuration dependency,
  +                                                  final boolean flag )
           throws ConfigurationException
       {
  -        final ServiceDescriptor service = buildService( dependency.getChild( "service" ) );
  +        ServiceDescriptor service;
  +        if( flag )
  +        {
  +            service = buildService( dependency.getChild( "reference" ), flag );
  +        }
  +        else
  +        {
  +            service = buildService( dependency.getChild( "service" ), flag );
  +        }
  +
           String role = dependency.getChild( "role" ).getValue( null );
   
           //default to name of service if role unspecified
  @@ -144,9 +186,10 @@
        *
        * @param servicesSet the services configuration
        * @return the created ServiceDescriptor
  +     * @param flag if TRUE build services using the Avalon Type DTD
        * @throws ConfigurationException if an error occurs
        */
  -    private ServiceDescriptor[] buildServices( final Configuration servicesSet )
  +    private ServiceDescriptor[] buildServices( final Configuration servicesSet, boolean flag )
           throws ConfigurationException
       {
           final Configuration[] elements = servicesSet.getChildren( "service" );
  @@ -154,7 +197,7 @@
   
           for( int i = 0; i < elements.length; i++ )
           {
  -            final ServiceDescriptor service = buildService( elements[ i ] );
  +            final ServiceDescriptor service = buildService( elements[ i ], flag );
               services.add( service );
           }
   
  @@ -167,15 +210,27 @@
        *
        * @param service the service Configuration
        * @return the created ServiceDescriptor
  +     * @param flag if TRUE build service using the Avalon Type DTD
        * @throws ConfigurationException if an error occurs
        */
  -    private ServiceDescriptor buildService( final Configuration service )
  +    private ServiceDescriptor buildService( final Configuration service, boolean flag )
           throws ConfigurationException
       {
  -        final String name = service.getAttribute( "name" );
  -        final String versionString = service.getAttribute( "version", "1.0" );
  -        final Version version = buildVersion( versionString );
  -        return new ServiceDescriptor( name, version );
  +        if( flag )
  +        {
  +            Configuration ref = service.getChild("reference");
  +            final String name = ref.getAttribute( "type" );
  +            final String versionString = ref.getAttribute( "version", "1.0" );
  +            final Version version = buildVersion( versionString );
  +            return new ServiceDescriptor( name, version );
  +        }
  +        else
  +        {
  +            final String name = service.getAttribute( "name" );
  +            final String versionString = service.getAttribute( "version", "1.0" );
  +            final Version version = buildVersion( versionString );
  +            return new ServiceDescriptor( name, version );
  +        }
       }
   
       /**
  @@ -188,11 +243,13 @@
        *
        * @param classname The classname of Block (used to create descriptor)
        * @param block the Block Configuration
  +     * @param flag if TRUE build descriptor using the Avalon Type DTD
        * @return the created BlockDescriptor
        * @throws ConfigurationException if an error occurs
        */
       private BlockDescriptor buildBlockDescriptor( final String classname,
  -                                                  final Configuration block )
  +                                                  final Configuration block,
  +                                                  final boolean flag )
           throws ConfigurationException
       {
           if( 0 == block.getChildren().length )
  @@ -204,11 +261,39 @@
               return null;
           }
   
  -        final String name = block.getChild( "name" ).getValue( null );
           final Version version = buildVersion( block.getChild( "version" ).getValue() );
  -        final String schemaType = block.getChild( "schema-type" ).getValue( null );
  +        final String name = block.getChild( "name" ).getValue( null );
  +
  +        String schemaType;
  +        if( flag )
  +        {
  +             schemaType = getSchemaAttribute( block.getChild( "attributes" ) );
  +        }
  +        else
  +        {
  +             schemaType = block.getChild( "schema-type" ).getValue( null );
  +        }
   
           return new BlockDescriptor( name, classname, schemaType, version );
  +    }
  +
  +    /**
  +     * A utility method to get a schema attribute from a configuration.
  +     *
  +     * @param config a configuration representing an Attributes element
  +     * @return the schema name (possible null if undefined)
  +     * @throws ConfigurationException if an error occurs
  +     */
  +    private String getSchemaAttribute( Configuration config ) throws ConfigurationException
  +    {
  +        Configuration[] attributes = config.getChildren("attribute");
  +        for( int i=0; i<attributes.length; i++ )
  +        {
  +            Configuration attribute = attributes[i];
  +            if( attribute.getAttribute("key").equals("phoenix:shema-type") )
  +              return attribute.getAttribute("value");
  +        }
  +        return null;
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/infobuilder BlockInfoBuilder.java

Posted by Stephen McConnell <mc...@apache.org>.
This one is interesting!

You doing a -1 on the commit from Pete Royal which is based on code 
contributed by myself.  As far as I can see I can -1 your -1 so here is 
my formal -1 opposing your -1.  Now, if we treck back through the CVS 
emails, I'm sure your can come up with my original commit (which is the 
one you should be doing your -1 on, not this one.  Assuming you mange to 
sort this out, I'll look forward to -1 your -1 on my contribution on the 
grounds that your objectives were inconsistent with the change.

To save you the time - here is a brief summary - back on the 14 Aug, 
Paul initiated a thread concerning the Features for the next Phoenix 
beta.  As a part of that thread I proposed that as a minimum we add 
support inside Phoenix for both the blockinfo and type DTD.  You 
responded to that email with the deep and meaningful contribution quoted 
below:


Peter Donald wrote:

>On Wed, 14 Aug 2002 21:31, Stephen McConnell wrote:
>
>>     Independently of question concerning meta-models, we must at least
>>     ensure that Phoenix provides support for Type DTD in order to ensure
>>     interoperability.
>>
>
>It won't.
>

I would like to point out to you that you did not -1 the proposed action. Subsequently Pete Royal requested an explanation to which you responded and provided inaccurate information.  Following a more detail message from myself that you did not reply to, oppose, or question, Paul requested that I go ahead and put in place the code that was discussed.  You replied to Pete's email raising issued concerning meta-info APIs when in fact the topic had nothing to do with meta-info, just the DTD - however, perhaps this was a temporary lapse of memory on your part - don't worry, you can probably get medication for that even in Australia.  Bottom line - Pete - this was discussed, implemented, enhanced, and now your screwing around trying to pull -1s and all that sort of rubbish.  Please - please - get of your lazy arse and explain what you problem is - put forward a constructive proposal - be creative!  Be you usual opinionated self because you believe in what your saying - not just because your pissed-off about something.

Cheers, Steve.




Peter Donald wrote:

>-1 for reasons already stated.
>
>On Fri, 16 Aug 2002 21:48, mcconnell@apache.org wrote:
>  
>
>>mcconnell    2002/08/16 04:48:12
>>
>>  Modified:    src/java/org/apache/avalon/phoenix/tools/infobuilder
>>                        BlockInfoBuilder.java
>>  Log:
>>  Updated to support both the Phoenix blockinfo and the Avalon Type DTD for
>>the xinfo file.
>>
>>  Revision  Changes    Path
>>  1.21      +106 -21  
>>jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/infobuilder
>>/BlockInfoBuilder.java
>>
>>  Index: BlockInfoBuilder.java
>>  ===================================================================
>>  RCS file:
>>/home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/i
>>nfobuilder/BlockInfoBuilder.java,v retrieving revision 1.20
>>  retrieving revision 1.21
>>  diff -u -r1.20 -r1.21
>>  --- BlockInfoBuilder.java	6 Aug 2002 11:57:42 -0000	1.20
>>  +++ BlockInfoBuilder.java	16 Aug 2002 11:48:12 -0000	1.21
>>  @@ -24,7 +24,8 @@
>>    * objects from Configuration objects. The format for Configuration
>>object * is specified in the BlockInfo specification.
>>    *
>>  - * @author <a href="mailto:peter at apache.org">Peter Donald</a>
>>  + * @author <a href="mailto:peter@apache.org">Peter Donald</a>
>>  + * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
>>    * @version $Revision$ $Date$
>>    */
>>   public final class BlockInfoBuilder
>>  @@ -51,19 +52,47 @@
>>               getLogger().debug( message );
>>           }
>>
>>  +        final boolean flag = info.getName().equals("type");
>>  +
>>  +        if( flag )
>>  +        {
>>  +            if( info.getChild("stages", false ) != null )
>>  +            {
>>  +                final String error =
>>  +                 "Poenix does not support components declaring phase
>>extension dependecies." +                 + " Class: " + classname;
>>  +                throw new IllegalArgumentException( error );
>>  +            }
>>  +            if( info.getChild("extensions", false ) != null )
>>  +            {
>>  +                final String error =
>>  +                 "Poenix does not support components declaring phase
>>extension handlers." +                 + " Class: " + classname;
>>  +                throw new IllegalArgumentException( error );
>>  +            }
>>  +        }
>>  +
>>           Configuration configuration = null;
>>
>>           configuration = info.getChild( "services" );
>>  -        final ServiceDescriptor[] services = buildServices(
>>configuration ); +        final ServiceDescriptor[] services =
>>buildServices( configuration, flag );
>>
>>           configuration = info.getChild( "management-access-points" );
>>  -        final ServiceDescriptor[] management = buildServices(
>>configuration ); +        final ServiceDescriptor[] management =
>>buildServices( configuration, flag );
>>
>>           configuration = info.getChild( "dependencies" );
>>  -        final DependencyDescriptor[] dependencies = buildDependencies(
>>classname, configuration ); +        final DependencyDescriptor[]
>>dependencies = buildDependencies( classname, configuration, flag );
>>
>>  -        configuration = info.getChild( "block" );
>>  -        final BlockDescriptor descriptor = buildBlockDescriptor(
>>classname, configuration ); +        if( flag )
>>  +        {
>>  +            configuration = info.getChild( "component" );
>>  +        }
>>  +        else
>>  +        {
>>  +            configuration = info.getChild( "block" );
>>  +        }
>>  +
>>  +        final BlockDescriptor descriptor = buildBlockDescriptor(
>>classname, configuration, flag );
>>
>>           if( getLogger().isDebugEnabled() )
>>           {
>>  @@ -83,11 +112,13 @@
>>        *
>>        * @param classname The classname of Block (used for logging
>>purposes) * @param configuration the dependencies configuration
>>  +     * @param flag if TRUE build dependencies using the Avalon Type DTD
>>        * @return the created DependencyDescriptor
>>        * @throws ConfigurationException if an error occurs
>>        */
>>       private DependencyDescriptor[] buildDependencies( final String
>>classname, -                                                      final
>>Configuration configuration ) +                                            
>>         final Configuration configuration, +                              
>>                       final boolean flag ) throws ConfigurationException
>>       {
>>           final Configuration[] elements = configuration.getChildren(
>>"dependency" ); @@ -96,7 +127,7 @@
>>           for( int i = 0; i < elements.length; i++ )
>>           {
>>               final DependencyDescriptor dependency =
>>  -                buildDependency( classname, elements[ i ] );
>>  +                buildDependency( classname, elements[ i ], flag );
>>               dependencies.add( dependency );
>>           }
>>
>>  @@ -109,14 +140,25 @@
>>        *
>>        * @param classname The classname of Block (used for logging
>>purposes) * @param dependency the dependency configuration
>>  +     * @param flag if TRUE build dependency using the Avalon Type DTD
>>        * @return the created DependencyDescriptor
>>        * @throws ConfigurationException if an error occurs
>>        */
>>       private DependencyDescriptor buildDependency( final String
>>classname, -                                                  final
>>Configuration dependency ) +                                               
>>  final Configuration dependency, +                                        
>>         final boolean flag ) throws ConfigurationException
>>       {
>>  -        final ServiceDescriptor service = buildService(
>>dependency.getChild( "service" ) ); +        ServiceDescriptor service;
>>  +        if( flag )
>>  +        {
>>  +            service = buildService( dependency.getChild( "reference" ),
>>flag ); +        }
>>  +        else
>>  +        {
>>  +            service = buildService( dependency.getChild( "service" ),
>>flag ); +        }
>>  +
>>           String role = dependency.getChild( "role" ).getValue( null );
>>
>>           //default to name of service if role unspecified
>>  @@ -144,9 +186,10 @@
>>        *
>>        * @param servicesSet the services configuration
>>        * @return the created ServiceDescriptor
>>  +     * @param flag if TRUE build services using the Avalon Type DTD
>>        * @throws ConfigurationException if an error occurs
>>        */
>>  -    private ServiceDescriptor[] buildServices( final Configuration
>>servicesSet ) +    private ServiceDescriptor[] buildServices( final
>>Configuration servicesSet, boolean flag ) throws ConfigurationException
>>       {
>>           final Configuration[] elements = servicesSet.getChildren(
>>"service" ); @@ -154,7 +197,7 @@
>>
>>           for( int i = 0; i < elements.length; i++ )
>>           {
>>  -            final ServiceDescriptor service = buildService( elements[ i
>>] ); +            final ServiceDescriptor service = buildService( elements[
>>i ], flag ); services.add( service );
>>           }
>>
>>  @@ -167,15 +210,27 @@
>>        *
>>        * @param service the service Configuration
>>        * @return the created ServiceDescriptor
>>  +     * @param flag if TRUE build service using the Avalon Type DTD
>>        * @throws ConfigurationException if an error occurs
>>        */
>>  -    private ServiceDescriptor buildService( final Configuration service
>>) +    private ServiceDescriptor buildService( final Configuration service,
>>boolean flag ) throws ConfigurationException
>>       {
>>  -        final String name = service.getAttribute( "name" );
>>  -        final String versionString = service.getAttribute( "version",
>>"1.0" ); -        final Version version = buildVersion( versionString );
>>  -        return new ServiceDescriptor( name, version );
>>  +        if( flag )
>>  +        {
>>  +            Configuration ref = service.getChild("reference");
>>  +            final String name = ref.getAttribute( "type" );
>>  +            final String versionString = ref.getAttribute( "version",
>>"1.0" ); +            final Version version = buildVersion( versionString
>>); +            return new ServiceDescriptor( name, version );
>>  +        }
>>  +        else
>>  +        {
>>  +            final String name = service.getAttribute( "name" );
>>  +            final String versionString = service.getAttribute(
>>"version", "1.0" ); +            final Version version = buildVersion(
>>versionString ); +            return new ServiceDescriptor( name, version
>>);
>>  +        }
>>       }
>>
>>       /**
>>  @@ -188,11 +243,13 @@
>>        *
>>        * @param classname The classname of Block (used to create
>>descriptor) * @param block the Block Configuration
>>  +     * @param flag if TRUE build descriptor using the Avalon Type DTD
>>        * @return the created BlockDescriptor
>>        * @throws ConfigurationException if an error occurs
>>        */
>>       private BlockDescriptor buildBlockDescriptor( final String
>>classname, -                                                  final
>>Configuration block ) +                                                 
>>final Configuration block, +                                               
>>  final boolean flag ) throws ConfigurationException
>>       {
>>           if( 0 == block.getChildren().length )
>>  @@ -204,11 +261,39 @@
>>               return null;
>>           }
>>
>>  -        final String name = block.getChild( "name" ).getValue( null );
>>           final Version version = buildVersion( block.getChild( "version"
>>).getValue() ); -        final String schemaType = block.getChild(
>>"schema-type" ).getValue( null ); +        final String name =
>>block.getChild( "name" ).getValue( null ); +
>>  +        String schemaType;
>>  +        if( flag )
>>  +        {
>>  +             schemaType = getSchemaAttribute( block.getChild(
>>"attributes" ) ); +        }
>>  +        else
>>  +        {
>>  +             schemaType = block.getChild( "schema-type" ).getValue( null
>>); +        }
>>
>>           return new BlockDescriptor( name, classname, schemaType, version
>>); +    }
>>  +
>>  +    /**
>>  +     * A utility method to get a schema attribute from a configuration.
>>  +     *
>>  +     * @param config a configuration representing an Attributes element
>>  +     * @return the schema name (possible null if undefined)
>>  +     * @throws ConfigurationException if an error occurs
>>  +     */
>>  +    private String getSchemaAttribute( Configuration config ) throws
>>ConfigurationException +    {
>>  +        Configuration[] attributes = config.getChildren("attribute");
>>  +        for( int i=0; i<attributes.length; i++ )
>>  +        {
>>  +            Configuration attribute = attributes[i];
>>  +            if(
>>attribute.getAttribute("key").equals("phoenix:shema-type") ) +             
>>return attribute.getAttribute("value");
>>  +        }
>>  +        return null;
>>       }
>>
>>       /**
>>    
>>
>
>  
>

-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/infobuilder BlockInfoBuilder.java

Posted by Peter Donald <pe...@apache.org>.
-1 for reasons already stated.

On Fri, 16 Aug 2002 21:48, mcconnell@apache.org wrote:
> mcconnell    2002/08/16 04:48:12
>
>   Modified:    src/java/org/apache/avalon/phoenix/tools/infobuilder
>                         BlockInfoBuilder.java
>   Log:
>   Updated to support both the Phoenix blockinfo and the Avalon Type DTD for
> the xinfo file.
>
>   Revision  Changes    Path
>   1.21      +106 -21  
> jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/infobuilder
>/BlockInfoBuilder.java
>
>   Index: BlockInfoBuilder.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/i
>nfobuilder/BlockInfoBuilder.java,v retrieving revision 1.20
>   retrieving revision 1.21
>   diff -u -r1.20 -r1.21
>   --- BlockInfoBuilder.java	6 Aug 2002 11:57:42 -0000	1.20
>   +++ BlockInfoBuilder.java	16 Aug 2002 11:48:12 -0000	1.21
>   @@ -24,7 +24,8 @@
>     * objects from Configuration objects. The format for Configuration
> object * is specified in the BlockInfo specification.
>     *
>   - * @author <a href="mailto:peter at apache.org">Peter Donald</a>
>   + * @author <a href="mailto:peter@apache.org">Peter Donald</a>
>   + * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
>     * @version $Revision$ $Date$
>     */
>    public final class BlockInfoBuilder
>   @@ -51,19 +52,47 @@
>                getLogger().debug( message );
>            }
>
>   +        final boolean flag = info.getName().equals("type");
>   +
>   +        if( flag )
>   +        {
>   +            if( info.getChild("stages", false ) != null )
>   +            {
>   +                final String error =
>   +                 "Poenix does not support components declaring phase
> extension dependecies." +                 + " Class: " + classname;
>   +                throw new IllegalArgumentException( error );
>   +            }
>   +            if( info.getChild("extensions", false ) != null )
>   +            {
>   +                final String error =
>   +                 "Poenix does not support components declaring phase
> extension handlers." +                 + " Class: " + classname;
>   +                throw new IllegalArgumentException( error );
>   +            }
>   +        }
>   +
>            Configuration configuration = null;
>
>            configuration = info.getChild( "services" );
>   -        final ServiceDescriptor[] services = buildServices(
> configuration ); +        final ServiceDescriptor[] services =
> buildServices( configuration, flag );
>
>            configuration = info.getChild( "management-access-points" );
>   -        final ServiceDescriptor[] management = buildServices(
> configuration ); +        final ServiceDescriptor[] management =
> buildServices( configuration, flag );
>
>            configuration = info.getChild( "dependencies" );
>   -        final DependencyDescriptor[] dependencies = buildDependencies(
> classname, configuration ); +        final DependencyDescriptor[]
> dependencies = buildDependencies( classname, configuration, flag );
>
>   -        configuration = info.getChild( "block" );
>   -        final BlockDescriptor descriptor = buildBlockDescriptor(
> classname, configuration ); +        if( flag )
>   +        {
>   +            configuration = info.getChild( "component" );
>   +        }
>   +        else
>   +        {
>   +            configuration = info.getChild( "block" );
>   +        }
>   +
>   +        final BlockDescriptor descriptor = buildBlockDescriptor(
> classname, configuration, flag );
>
>            if( getLogger().isDebugEnabled() )
>            {
>   @@ -83,11 +112,13 @@
>         *
>         * @param classname The classname of Block (used for logging
> purposes) * @param configuration the dependencies configuration
>   +     * @param flag if TRUE build dependencies using the Avalon Type DTD
>         * @return the created DependencyDescriptor
>         * @throws ConfigurationException if an error occurs
>         */
>        private DependencyDescriptor[] buildDependencies( final String
> classname, -                                                      final
> Configuration configuration ) +                                            
>          final Configuration configuration, +                              
>                        final boolean flag ) throws ConfigurationException
>        {
>            final Configuration[] elements = configuration.getChildren(
> "dependency" ); @@ -96,7 +127,7 @@
>            for( int i = 0; i < elements.length; i++ )
>            {
>                final DependencyDescriptor dependency =
>   -                buildDependency( classname, elements[ i ] );
>   +                buildDependency( classname, elements[ i ], flag );
>                dependencies.add( dependency );
>            }
>
>   @@ -109,14 +140,25 @@
>         *
>         * @param classname The classname of Block (used for logging
> purposes) * @param dependency the dependency configuration
>   +     * @param flag if TRUE build dependency using the Avalon Type DTD
>         * @return the created DependencyDescriptor
>         * @throws ConfigurationException if an error occurs
>         */
>        private DependencyDescriptor buildDependency( final String
> classname, -                                                  final
> Configuration dependency ) +                                               
>   final Configuration dependency, +                                        
>          final boolean flag ) throws ConfigurationException
>        {
>   -        final ServiceDescriptor service = buildService(
> dependency.getChild( "service" ) ); +        ServiceDescriptor service;
>   +        if( flag )
>   +        {
>   +            service = buildService( dependency.getChild( "reference" ),
> flag ); +        }
>   +        else
>   +        {
>   +            service = buildService( dependency.getChild( "service" ),
> flag ); +        }
>   +
>            String role = dependency.getChild( "role" ).getValue( null );
>
>            //default to name of service if role unspecified
>   @@ -144,9 +186,10 @@
>         *
>         * @param servicesSet the services configuration
>         * @return the created ServiceDescriptor
>   +     * @param flag if TRUE build services using the Avalon Type DTD
>         * @throws ConfigurationException if an error occurs
>         */
>   -    private ServiceDescriptor[] buildServices( final Configuration
> servicesSet ) +    private ServiceDescriptor[] buildServices( final
> Configuration servicesSet, boolean flag ) throws ConfigurationException
>        {
>            final Configuration[] elements = servicesSet.getChildren(
> "service" ); @@ -154,7 +197,7 @@
>
>            for( int i = 0; i < elements.length; i++ )
>            {
>   -            final ServiceDescriptor service = buildService( elements[ i
> ] ); +            final ServiceDescriptor service = buildService( elements[
> i ], flag ); services.add( service );
>            }
>
>   @@ -167,15 +210,27 @@
>         *
>         * @param service the service Configuration
>         * @return the created ServiceDescriptor
>   +     * @param flag if TRUE build service using the Avalon Type DTD
>         * @throws ConfigurationException if an error occurs
>         */
>   -    private ServiceDescriptor buildService( final Configuration service
> ) +    private ServiceDescriptor buildService( final Configuration service,
> boolean flag ) throws ConfigurationException
>        {
>   -        final String name = service.getAttribute( "name" );
>   -        final String versionString = service.getAttribute( "version",
> "1.0" ); -        final Version version = buildVersion( versionString );
>   -        return new ServiceDescriptor( name, version );
>   +        if( flag )
>   +        {
>   +            Configuration ref = service.getChild("reference");
>   +            final String name = ref.getAttribute( "type" );
>   +            final String versionString = ref.getAttribute( "version",
> "1.0" ); +            final Version version = buildVersion( versionString
> ); +            return new ServiceDescriptor( name, version );
>   +        }
>   +        else
>   +        {
>   +            final String name = service.getAttribute( "name" );
>   +            final String versionString = service.getAttribute(
> "version", "1.0" ); +            final Version version = buildVersion(
> versionString ); +            return new ServiceDescriptor( name, version
> );
>   +        }
>        }
>
>        /**
>   @@ -188,11 +243,13 @@
>         *
>         * @param classname The classname of Block (used to create
> descriptor) * @param block the Block Configuration
>   +     * @param flag if TRUE build descriptor using the Avalon Type DTD
>         * @return the created BlockDescriptor
>         * @throws ConfigurationException if an error occurs
>         */
>        private BlockDescriptor buildBlockDescriptor( final String
> classname, -                                                  final
> Configuration block ) +                                                 
> final Configuration block, +                                               
>   final boolean flag ) throws ConfigurationException
>        {
>            if( 0 == block.getChildren().length )
>   @@ -204,11 +261,39 @@
>                return null;
>            }
>
>   -        final String name = block.getChild( "name" ).getValue( null );
>            final Version version = buildVersion( block.getChild( "version"
> ).getValue() ); -        final String schemaType = block.getChild(
> "schema-type" ).getValue( null ); +        final String name =
> block.getChild( "name" ).getValue( null ); +
>   +        String schemaType;
>   +        if( flag )
>   +        {
>   +             schemaType = getSchemaAttribute( block.getChild(
> "attributes" ) ); +        }
>   +        else
>   +        {
>   +             schemaType = block.getChild( "schema-type" ).getValue( null
> ); +        }
>
>            return new BlockDescriptor( name, classname, schemaType, version
> ); +    }
>   +
>   +    /**
>   +     * A utility method to get a schema attribute from a configuration.
>   +     *
>   +     * @param config a configuration representing an Attributes element
>   +     * @return the schema name (possible null if undefined)
>   +     * @throws ConfigurationException if an error occurs
>   +     */
>   +    private String getSchemaAttribute( Configuration config ) throws
> ConfigurationException +    {
>   +        Configuration[] attributes = config.getChildren("attribute");
>   +        for( int i=0; i<attributes.length; i++ )
>   +        {
>   +            Configuration attribute = attributes[i];
>   +            if(
> attribute.getAttribute("key").equals("phoenix:shema-type") ) +             
> return attribute.getAttribute("value");
>   +        }
>   +        return null;
>        }
>
>        /**

-- 
Cheers,

Peter Donald
*----------------------------------------------------------*
The phrase "computer literate user" really means the person 
has been hurt so many times that the scar tissue is thick 
enough so he no longer feels the pain. 
   -- Alan Cooper, The Inmates are Running the Asylum 
*----------------------------------------------------------*


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>