-1 for reasons already stated. On Fri, 16 Aug 2002 21:48, [EMAIL PROTECTED] 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:[EMAIL PROTECTED]">Peter Donald</a> > + * @author <a href="mailto:[EMAIL PROTECTED]">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: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
