hammant 2002/11/28 13:27:53 Modified: containerkit default.properties containerkit/src/java/org/apache/excalibur/containerkit/demo SimpleMetaDataBuilder.java SimpleServiceKernel.java containerkit/src/java/org/apache/excalibur/containerkit/kernel/processor DependencyMap.java containerkit/src/java/org/apache/excalibur/containerkit/lifecycle/impl AbstractResourceProvider.java Resource.properties containerkit/src/java/org/apache/excalibur/containerkit/metadata ComponentMetaData.java DependencyMetaData.java MetaDataBuilder.java package.html containerkit/src/java/org/apache/excalibur/containerkit/registry ComponentProfile.java containerkit/src/java/org/apache/excalibur/containerkit/verifier AssemblyVerifier.java info/src/java/org/apache/avalon/framework/info Attribute.java ComponentInfo.java ContextDescriptor.java DependencyDescriptor.java EntryDescriptor.java LoggerDescriptor.java ServiceDescriptor.java info/src/java/org/apache/avalon/framework/tools/ant FormatEnum.java MetaGenerateTask.java info/src/java/org/apache/avalon/framework/tools/infobuilder InfoBuilder.java LegacyBlockInfoReader.java XMLInfoReader.java XMLInfoWriter.java info/src/java/org/apache/avalon/framework/tools/qdox AbstractInfoBuilder.java DefaultInfoBuilder.java LegacyInfoBuilder.java info/src/java/org/apache/avalon/framework/tools/verifier InfoVerifier.java info/src/test/org/apache/avalon/framework/tools/infobuilder/test InfoAssert.java InfoBuilderTestCase.java info/src/test/org/apache/avalon/framework/tools/infobuilder/test/data QDoxLegacyComponent1-info.xml QDoxLegacyComponent1.java component2.xinfo component3-info.xml sourceresolve/src/java/org/apache/excalibur/source/impl SourceResolverImpl.java Log: From PeterD... It does a bunch of things. Basically it adds support for "Partitions" which are groupings of components that are operated on in concert. ie The listeners in phoenix would be one partition and the blocks would be another. Nothing particularly earth shattering and it essentially follows the design of HP's CSF. The patch also copies back the array/map dependency stuff from phoenix into containerkit. It also adds the notion of attributes to the metadata/assembly declarations. It also vastly imprves the memory management not requiring so many instantiations and dealing with nulls in some cases and defining empty arrays in others. It also vastly improves the support for handling BlockInfo style metadata, including offering writing support. Also implements proper mapping of phoenix style short names for schema (ie relax-ng) ro uri based names (ie http://www.relaxng ....). Which makes it easier to support a larger variety of schema languages to be used in the future. Revision Changes Path 1.6 +1 -1 jakarta-avalon-excalibur/containerkit/default.properties Index: default.properties =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/default.properties,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- default.properties 16 Nov 2002 12:08:50 -0000 1.5 +++ default.properties 28 Nov 2002 21:27:51 -0000 1.6 @@ -8,7 +8,7 @@ name=excalibur-containerkit Name=Excalibur ContainerKit dir-name=containerkit -version=1.0 +version=1.0a package-version=0.99 year=2000-2002 1.2 +23 -6 jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/demo/SimpleMetaDataBuilder.java Index: SimpleMetaDataBuilder.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/demo/SimpleMetaDataBuilder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SimpleMetaDataBuilder.java 23 Aug 2002 08:51:15 -0000 1.1 +++ SimpleMetaDataBuilder.java 28 Nov 2002 21:27:51 -0000 1.2 @@ -8,12 +8,15 @@ package org.apache.excalibur.containerkit.demo; import java.util.ArrayList; +import java.util.Map; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; +import org.apache.avalon.framework.info.Attribute; import org.apache.excalibur.containerkit.metadata.ComponentMetaData; import org.apache.excalibur.containerkit.metadata.DependencyMetaData; import org.apache.excalibur.containerkit.metadata.MetaDataBuilder; +import org.apache.excalibur.containerkit.metadata.PartitionMetaData; import org.xml.sax.InputSource; /** @@ -26,7 +29,20 @@ public class SimpleMetaDataBuilder implements MetaDataBuilder { - public ComponentMetaData[] loadMetaData( final String location ) + public static final String CONFIG_LOCATION = "simple:location"; + + public PartitionMetaData buildAssembly( final Map parameters ) + throws Exception + { + final String location = (String)parameters.get( CONFIG_LOCATION ); + final ComponentMetaData[] components = loadMetaData( location ); + return new PartitionMetaData( "main", new String[ 0 ], + new PartitionMetaData[ 0 ], + components, + Attribute.EMPTY_SET ); + } + + private ComponentMetaData[] loadMetaData( final String location ) throws Exception { final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(); @@ -62,7 +78,7 @@ final DependencyMetaData[] dependencies = parseAssociations( component.getChildren( "provide" ) ); - return new ComponentMetaData( name, impl, dependencies, null, config ); + return new ComponentMetaData( name, impl, dependencies, null, config, null ); } private DependencyMetaData[] parseAssociations( final Configuration[] provides ) @@ -72,9 +88,10 @@ for( int i = 0; i < provides.length; i++ ) { final Configuration provide = provides[ i ]; - final String role = provide.getAttribute( "role" ); - final String provider = provide.getAttribute( "name" ); - final DependencyMetaData association = new DependencyMetaData( role, provider ); + final String key = provide.getAttribute( "key" ); + final String provider = provide.getAttribute( "provider" ); + final DependencyMetaData association = + new DependencyMetaData( key, provider, key, Attribute.EMPTY_SET ); associations.add( association ); } return (DependencyMetaData[])associations.toArray( new DependencyMetaData[ associations.size() ] ); 1.3 +8 -2 jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/demo/SimpleServiceKernel.java Index: SimpleServiceKernel.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/demo/SimpleServiceKernel.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- SimpleServiceKernel.java 2 Oct 2002 01:52:19 -0000 1.2 +++ SimpleServiceKernel.java 28 Nov 2002 21:27:51 -0000 1.3 @@ -18,6 +18,9 @@ import org.apache.excalibur.containerkit.lifecycle.ResourceProvider; import org.apache.excalibur.containerkit.metadata.ComponentMetaData; import org.apache.excalibur.containerkit.metadata.MetaDataBuilder; +import org.apache.excalibur.containerkit.metadata.PartitionMetaData; +import java.util.Map; +import java.util.HashMap; /** * This is a simple ServiceKernel. @@ -53,7 +56,10 @@ m_metaDataBuilder = new SimpleMetaDataBuilder(); setupLogger( getFactory(), "builder" ); - final ComponentMetaData[] components = m_metaDataBuilder.loadMetaData( m_configURL ); + final Map parameters = new HashMap(); + parameters.put( SimpleMetaDataBuilder.CONFIG_LOCATION, m_configURL ); + final PartitionMetaData partition = m_metaDataBuilder.buildAssembly( parameters ); + final ComponentMetaData[] components = partition.getComponents(); for( int i = 0; i < components.length; i++ ) { final ComponentMetaData component = components[ i ]; 1.3 +4 -4 jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/kernel/processor/DependencyMap.java Index: DependencyMap.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/kernel/processor/DependencyMap.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DependencyMap.java 2 Oct 2002 01:52:19 -0000 1.2 +++ DependencyMap.java 28 Nov 2002 21:27:52 -0000 1.3 @@ -217,12 +217,12 @@ for( int i = 0; i < entrySet.length; i++ ) { final ComponentProfile other = entrySet[ i ]; - final DependencyMetaData[] roles = + final DependencyMetaData[] dependencies = other.getMetaData().getDependencies(); - for( int j = 0; j < roles.length; j++ ) + for( int j = 0; j < dependencies.length; j++ ) { - final String depends = roles[ j ].getProviderName(); + final String depends = dependencies[ j ].getProviderName(); if( depends.equals( name ) ) { visitcomponent( other, false, done, order, store ); 1.20 +6 -6 jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/lifecycle/impl/AbstractResourceProvider.java Index: AbstractResourceProvider.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/lifecycle/impl/AbstractResourceProvider.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- AbstractResourceProvider.java 16 Nov 2002 13:09:33 -0000 1.19 +++ AbstractResourceProvider.java 28 Nov 2002 21:27:52 -0000 1.20 @@ -339,7 +339,7 @@ /** * Create a Map of services for specified component. - * The map maps role name to service provider. + * The map maps key name to service provider. * * @param componentEntry the component entry creating map for * @return the map @@ -359,9 +359,9 @@ for( int i = 0; i < dependencies.length; i++ ) { final DependencyMetaData dependency = dependencies[ i ]; - final String role = dependency.getRole(); + final String key = dependency.getKey(); final String providerName = dependency.getProviderName(); - final boolean optional = info.getDependency( role ).isOptional(); + final boolean optional = info.getDependency( key ).isOptional(); final Object service = getService( providerName, componentEntry ); @@ -370,7 +370,7 @@ final String message = REZ.getString( "resource.missing-dependency.error", optional ? "1" : "2", - role, + key, component.getName() ); if( !optional ) { @@ -383,7 +383,7 @@ } } - services.put( role, service ); + services.put( key, service ); } return services; 1.3 +2 -2 jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/lifecycle/impl/Resource.properties Index: Resource.properties =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/lifecycle/impl/Resource.properties,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Resource.properties 25 Jun 2002 04:32:29 -0000 1.2 +++ Resource.properties 28 Nov 2002 21:27:52 -0000 1.3 @@ -1,7 +1,7 @@ resource.missing-context-value.error=Missing {0,choice,1#Optional|2#Required} Context Entry with key "{1}" for component named "{2}". resource.bad-value-type.error=Bad value retrieved for {0,choice,1#Optional|2#Required} Context Entry with key "{1}" for component named "{2}". Expected to be of type "{3}" but was of type "{4}". resource.bad-context-type.error=The class of Contex object for component named "{2}" was expected to be of type {0} but was of tpye {1}. -resource.service-not-a-component.error=The service with role "0" and implemenation class "{1}" does not implement the Component interface but is being exposed via ComponentManager. -resource.missing-dependency.error=Missing {0,choice,1#Optional|2#Required} dependency with role "{1}" for component named {2}. +resource.service-not-a-component.error=The service with key "0" and implemenation class "{1}" does not implement the Component interface but is being exposed via ComponentManager. +resource.missing-dependency.error=Missing {0,choice,1#Optional|2#Required} dependency with key "{1}" for component named {2}. resource.missing-parameters.error=Missing Parameters object for component named "{0}". resource.missing-parameters.error=Missing Configuration for component named "{0}". 1.14 +24 -15 jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metadata/ComponentMetaData.java Index: ComponentMetaData.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metadata/ComponentMetaData.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- ComponentMetaData.java 18 Aug 2002 03:34:28 -0000 1.13 +++ ComponentMetaData.java 28 Nov 2002 21:27:52 -0000 1.14 @@ -8,11 +8,13 @@ package org.apache.excalibur.containerkit.metadata; import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.info.Attribute; +import org.apache.avalon.framework.info.FeatureDescriptor; import org.apache.avalon.framework.parameters.Parameters; /** * Each component declared in the application is represented by - * a ComponentPolicy. Note that this does not necessarily imply + * a ComponentMetaData. Note that this does not necessarily imply * that there is only one instance of actual component. The * ComponentMetaData could represent a pool of components, a single * component or a component prototype that is reused to create @@ -22,8 +24,15 @@ * @version $Revision$ $Date$ */ public class ComponentMetaData + extends FeatureDescriptor { /** + * The name of the component. This is an + * abstract name used during assembly. + */ + private final String m_name; + + /** * The implementationKey for this component. * Usually this represents a classname but * alternative mechanisms could be used (ie URL @@ -32,12 +41,6 @@ private final String m_implementationKey; /** - * The name of the component. This is an - * abstract name used during assembly. - */ - private final String m_name; - - /** * The resolution of any dependencies required by * the component type. */ @@ -57,14 +60,20 @@ * Create a ComponentMetaData. * * @param name the abstract name of component meta data instance + * @param implementationKey the key used to create component (usually a classname) * @param dependencies the meta data for any dependencies + * @param parameters the parameters that the component will be provided (may be null) + * @param configuration the configuration that the component will be provided (may be null) + * @param attributes the extra attributes that are used to describe component */ public ComponentMetaData( final String name, final String implementationKey, final DependencyMetaData[] dependencies, final Parameters parameters, - final Configuration configuration ) + final Configuration configuration, + final Attribute[] attributes ) { + super( attributes ); if( null == name ) { throw new NullPointerException( "name" ); @@ -86,9 +95,9 @@ } /** - * Return the name of component profile. + * Return the name of component metadata. * - * @return the name of the component profile. + * @return the name of the component metadata. */ public String getName() { @@ -136,15 +145,15 @@ } /** - * Return the dependency for component with specified role. + * Return the dependency for component with specified key. * - * @return the dependency for component with specified role. + * @return the dependency for component with specified key. */ - public DependencyMetaData getDependency( final String role ) + public DependencyMetaData getDependency( final String key ) { for( int i = 0; i < m_dependencies.length; i++ ) { - if( m_dependencies[ i ].getRole().equals( role ) ) + if( m_dependencies[ i ].getKey().equals( key ) ) { return m_dependencies[ i ]; } 1.11 +51 -12 jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metadata/DependencyMetaData.java Index: DependencyMetaData.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metadata/DependencyMetaData.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- DependencyMetaData.java 2 Oct 2002 01:46:57 -0000 1.10 +++ DependencyMetaData.java 28 Nov 2002 21:27:52 -0000 1.11 @@ -7,12 +7,15 @@ */ package org.apache.excalibur.containerkit.metadata; +import org.apache.avalon.framework.info.FeatureDescriptor; +import org.apache.avalon.framework.info.Attribute; + /** * The [EMAIL PROTECTED] DependencyMetaData} is the mapping of a component as a dependency * of another component. Each component declares dependencies (via * [EMAIL PROTECTED] org.apache.avalon.framework.info.ComponentInfo}) * and for each dependency there must be a coressponding DependencyMetaData which - * has a matching role. The name value in [EMAIL PROTECTED] DependencyMetaData} object must refer + * has a matching key. The name value in [EMAIL PROTECTED] DependencyMetaData} object must refer * to another Component that implements a service as specified in DependencyInfo. * * <p>Note that it is invalid to have circular dependencies.</p> @@ -22,11 +25,12 @@ * @version $Revision$ $Date$ */ public final class DependencyMetaData + extends FeatureDescriptor { /** - * The name that the client component will use to access a dependency. + * The key that the client component will use to access a dependency. */ - private final String m_role; + private final String m_key; /** * the name of the component profile that represents a component @@ -35,29 +39,52 @@ private final String m_providerName; /** - * Create Association between role and provider. + * The key that is used when the dependency is a map dependency. + * Usually this defaults to the same value as the key. + */ + private final String m_alias; + + /** + * Create Association between key and provider. * - * @param role the name client uses to access component + * @param key the key the client uses to access component * @param providerName the name of [EMAIL PROTECTED] ComponentMetaData} * that is associated as a service provider */ - public DependencyMetaData( final String role, - final String providerName ) + public DependencyMetaData( final String key, + final String providerName, + final String alias, + final Attribute[] attributes ) { - m_role = role; + super( attributes ); + + if( null == key ) + { + throw new NullPointerException( "key" ); + } + if( null == providerName ) + { + throw new NullPointerException( "providerName" ); + } + if( null == alias ) + { + throw new NullPointerException( "alias" ); + } + m_key = key; m_providerName = providerName; + m_alias = alias; } /** - * Return the name that will be used by a component instance to access a + * Return the key that will be used by a component instance to access a * dependent service. * * @return the name that the client component will use to access dependency. * @see org.apache.avalon.framework.service.ServiceManager#lookup( String ) */ - public String getRole() + public String getKey() { - return m_role; + return m_key; } /** @@ -69,5 +96,17 @@ public String getProviderName() { return m_providerName; + } + + /** + * The key under which the dependency is placed in map if dependency is + * a Map dependency. + * + * @return the key under which the dependency is placed in map if dependency is + * a Map dependency. + */ + public String getAlias() + { + return m_alias; } } 1.3 +10 -11 jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metadata/MetaDataBuilder.java Index: MetaDataBuilder.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metadata/MetaDataBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MetaDataBuilder.java 2 Oct 2002 01:52:19 -0000 1.2 +++ MetaDataBuilder.java 28 Nov 2002 21:27:52 -0000 1.3 @@ -7,11 +7,11 @@ */ package org.apache.excalibur.containerkit.metadata; - +import java.util.Map; /** - * Load metadata from some source. The source is usually - * one or more xml config files. + * Load metadata for an Assembly from some source. + * The source is usually one or more xml config files. * * @author <a href="mailto:peter at apache.org">Peter Donald</a> * @version $Revision$ $Date$ @@ -20,15 +20,14 @@ { /** * Load metadata from a particular source - * defined by location string. The format of - * location string and format of source loaded - * from is left unspecified. + * using specified map of parameters. The content + * of the parameters is left unspecified. * - * @param location the location of meta data source + * @param parameters the parameters indicating method to load meta data source * @return the set of components in metadata - * @throws java.lang.Exception if unable to load or resolve meta - * data for any reason + * @throws Exception if unable to load or resolve + * meta data for any reason */ - ComponentMetaData[] loadMetaData( String location ) + PartitionMetaData buildAssembly( Map parameters ) throws Exception; } 1.3 +1 -2 jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metadata/package.html Index: package.html =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metadata/package.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- package.html 6 Jul 2002 01:13:01 -0000 1.2 +++ package.html 28 Nov 2002 21:27:52 -0000 1.3 @@ -1,5 +1,4 @@ - <body> A set of classes supporting the representation of information about a -component profile. +component assembly. </body> 1.2 +2 -1 jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/registry/ComponentProfile.java Index: ComponentProfile.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/registry/ComponentProfile.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ComponentProfile.java 24 Aug 2002 08:49:03 -0000 1.1 +++ ComponentProfile.java 28 Nov 2002 21:27:52 -0000 1.2 @@ -27,6 +27,7 @@ * the type of this component. */ private final ComponentInfo m_info; + /** * The [EMAIL PROTECTED] ComponentMetaData} that describes * this component. 1.41 +23 -23 jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/verifier/AssemblyVerifier.java Index: AssemblyVerifier.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/verifier/AssemblyVerifier.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- AssemblyVerifier.java 12 Nov 2002 01:39:42 -0000 1.40 +++ AssemblyVerifier.java 28 Nov 2002 21:27:52 -0000 1.41 @@ -37,7 +37,7 @@ * from Component B then Component B must provide Service S.</li> * <li>Verify that there are no circular dependendencies between * components.</li> - * <li>Verify that the Class objects for Component implement the + * <li>Verify that the Class objects for component implement the * service interfaces.</li> * <li>Verify that the Class is a valid Avalon Component as per the * rules in [EMAIL PROTECTED] org.apache.avalon.framework.tools.verifier.ComponentVerifier} object.</li> @@ -245,13 +245,14 @@ throws VerifyException { final ComponentInfo info = component.getInfo(); - final DependencyMetaData[] roles = component.getMetaData().getDependencies(); + final DependencyMetaData[] dependencies = component.getMetaData().getDependencies(); - for( int i = 0; i < roles.length; i++ ) + for( int i = 0; i < dependencies.length; i++ ) { - final String providerName = roles[ i ].getProviderName(); - final String roleName = roles[ i ].getRole(); - final String implementationKey = info.getDependency( roleName ).getType(); + final DependencyMetaData dependency = dependencies[ i ]; + final String providerName = dependency.getProviderName(); + final String key = dependency.getKey(); + final String type = info.getDependency( key ).getType(); //Get the other component that is providing service final ComponentProfile provider = getComponentProfile( providerName, others ); @@ -259,7 +260,7 @@ { final String message = REZ.getString( "assembly.missing-dependency.error", - roleName, + key, providerName, component.getMetaData().getName() ); throw new VerifyException( message ); @@ -269,12 +270,12 @@ //that user expects it to be providing final ComponentInfo providerInfo = provider.getInfo(); final ServiceDescriptor[] services = providerInfo.getServices(); - if( !hasMatchingService( implementationKey, services ) ) + if( !hasMatchingService( type, services ) ) { final String message = REZ.getString( "assembly.dependency-missing-service.error", providerName, - implementationKey, + type, component.getMetaData().getName() ); throw new VerifyException( message ); } @@ -404,15 +405,15 @@ protected void verifyDependenciesMap( final ComponentProfile component ) throws VerifyException { - //Make sure all role entries specified in config file are valid + //Make sure all dependency entries specified in config file are valid final DependencyMetaData[] dependencySet = component.getMetaData().getDependencies(); for( int i = 0; i < dependencySet.length; i++ ) { - final String roleName = dependencySet[ i ].getRole(); + final String key = dependencySet[ i ].getKey(); final ComponentInfo info = component.getInfo(); - final DependencyDescriptor descriptor = info.getDependency( roleName ); + final DependencyDescriptor descriptor = info.getDependency( key ); //If there is no dependency descriptor in ComponentInfo then //user has specified an uneeded dependency. @@ -420,8 +421,8 @@ { final String message = REZ.getString( "assembly.unknown-dependency.error", - roleName, - roleName, + key, + key, component.getMetaData().getName() ); throw new VerifyException( message ); } @@ -433,12 +434,12 @@ for( int i = 0; i < dependencies.length; i++ ) { final DependencyDescriptor dependency = dependencies[ i ]; - final DependencyMetaData role = + final DependencyMetaData dependencyMetaData = component.getMetaData().getDependency( dependency.getKey() ); - //If there is no Role then the user has failed + //If there is no metaData then the user has failed //to specify a needed dependency. - if( null == role && !dependency.isOptional() ) + if( null == dependencyMetaData && !dependency.isOptional() ) { final String message = REZ.getString( "assembly.unspecified-dependency.error", @@ -453,19 +454,18 @@ * Return true if specified service reference matches any of the * candidate services. * - * @param implementationKey the service implementationKey + * @param type the service type * @param candidates an array of candidate services * @return true if candidate services contains a service that matches * specified service, false otherwise */ - protected boolean hasMatchingService( final String implementationKey, + protected boolean hasMatchingService( final String type, final ServiceDescriptor[] candidates ) { for( int i = 0; i < candidates.length; i++ ) { - final String otherClassname = - candidates[ i ].getImplementationKey(); - if( otherClassname.equals( implementationKey ) ) + final String otherClassname = candidates[ i ].getType(); + if( otherClassname.equals( type ) ) { return true; } 1.7 +20 -9 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/Attribute.java Index: Attribute.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/Attribute.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Attribute.java 11 Nov 2002 23:56:53 -0000 1.6 +++ Attribute.java 28 Nov 2002 21:27:52 -0000 1.7 @@ -24,7 +24,15 @@ public final class Attribute implements Serializable { - private static final String[] EMPTY_SET = new String[ 0 ]; + /** + * An empty array of attributes. + */ + public static final Attribute[] EMPTY_SET = new Attribute[ 0 ]; + + /** + * To save memory always return same emtpy array of names + */ + private static final String[] EMPTY_NAME_SET = new String[ 0 ]; /** * The name of the Attribute. @@ -49,10 +57,6 @@ { throw new NullPointerException( "name" ); } - if( null == parameters ) - { - throw new NullPointerException( "parameters" ); - } m_name = name; m_parameters = parameters; @@ -112,16 +116,23 @@ { if( null == m_parameters ) { - return EMPTY_SET; + return EMPTY_NAME_SET; } else { - return (String[])m_parameters.keySet().toArray( EMPTY_SET ); + return (String[])m_parameters.keySet().toArray( EMPTY_NAME_SET ); } } public String toString() { - return getName() + m_parameters; + if( null != m_parameters ) + { + return getName() + m_parameters; + } + else + { + return getName(); + } } } 1.9 +2 -2 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/ComponentInfo.java Index: ComponentInfo.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/ComponentInfo.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ComponentInfo.java 24 Nov 2002 12:15:26 -0000 1.8 +++ ComponentInfo.java 28 Nov 2002 21:27:52 -0000 1.9 @@ -203,7 +203,7 @@ { for( int i = 0; i < m_services.length; i++ ) { - final String otherClassname = m_services[ i ].getImplementationKey(); + final String otherClassname = m_services[ i ].getType(); if( otherClassname.equals( classname ) ) { return m_services[ i ]; 1.11 +13 -1 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/ContextDescriptor.java Index: ContextDescriptor.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/ContextDescriptor.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ContextDescriptor.java 29 Sep 2002 04:13:47 -0000 1.10 +++ ContextDescriptor.java 28 Nov 2002 21:27:52 -0000 1.11 @@ -30,6 +30,18 @@ extends FeatureDescriptor { /** + * The default type of the context. + */ + public static final String DEFAULT_TYPE = + "org.apache.avalon.framework.context.Context"; + + /** + * A constant for an empty context with standard type. + */ + public static final ContextDescriptor EMPTY_CONTEXT = + new ContextDescriptor( DEFAULT_TYPE, EntryDescriptor.EMPTY_SET, Attribute.EMPTY_SET ); + + /** * The type of the context. (ie a name of the context * interface that is required by the component). */ 1.12 +62 -1 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/DependencyDescriptor.java Index: DependencyDescriptor.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/DependencyDescriptor.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- DependencyDescriptor.java 12 Nov 2002 01:33:14 -0000 1.11 +++ DependencyDescriptor.java 28 Nov 2002 21:27:52 -0000 1.12 @@ -36,6 +36,21 @@ extends FeatureDescriptor { /** + * Constant with empty set of dependencys. + */ + public static final DependencyDescriptor[] EMPTY_SET = new DependencyDescriptor[ 0 ]; + + /** + * The postfix indicating an array type. + */ + public static final String ARRAY_POSTFIX = "[]"; + + /** + * The postfix indicating a "Map" type. + */ + public static final String MAP_POSTFIX = "{}"; + + /** * The name the component uses to lookup dependency. */ private final String m_key; @@ -104,6 +119,52 @@ public boolean isOptional() { return m_optional; + } + + /** + * Return true if dependency type is an array. + * + * @return true if dependency type is an array. + */ + public boolean isArray() + { + return getType().endsWith( ARRAY_POSTFIX ); + } + + /** + * Return true if dependency type is a map. + * + * @return true if dependency type is a map. + */ + public boolean isMap() + { + return getType().endsWith( MAP_POSTFIX ); + } + + /** + * Return the type of component type if the service + * is an array or Map Service. Otherwise just return the + * name of service. + * + * @return the Service component type + */ + public String getComponentType() + { + final String fullname = getType(); + if( isArray() ) + { + final int end = fullname.length() - ARRAY_POSTFIX.length(); + return fullname.substring( 0, end ); + } + else if( isMap() ) + { + final int end = fullname.length() - MAP_POSTFIX.length(); + return fullname.substring( 0, end ); + } + else + { + return fullname; + } } /** 1.8 +6 -2 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/EntryDescriptor.java Index: EntryDescriptor.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/EntryDescriptor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- EntryDescriptor.java 29 Sep 2002 04:13:47 -0000 1.7 +++ EntryDescriptor.java 28 Nov 2002 21:27:52 -0000 1.8 @@ -35,6 +35,11 @@ implements Serializable { /** + * Emprty set of entrys. + */ + public static final EntryDescriptor[] EMPTY_SET = new EntryDescriptor[ 0 ]; + + /** * The name the component uses to lookup entry. */ private final String m_key; @@ -58,7 +63,6 @@ final Attribute[] attribute ) { super( attribute ); - if( null == key ) { throw new NullPointerException( "key" ); 1.7 +9 -1 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/LoggerDescriptor.java Index: LoggerDescriptor.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/LoggerDescriptor.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- LoggerDescriptor.java 29 Sep 2002 04:13:47 -0000 1.6 +++ LoggerDescriptor.java 28 Nov 2002 21:27:52 -0000 1.7 @@ -23,6 +23,14 @@ public class LoggerDescriptor extends FeatureDescriptor { + /** + * A empty array of logger descriptors + */ + public static final LoggerDescriptor[] EMPTY_SET = new LoggerDescriptor[ 0 ]; + + /** + * The name of the logger. + */ private final String m_name; /** 1.9 +15 -10 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/ServiceDescriptor.java Index: ServiceDescriptor.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/ServiceDescriptor.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ServiceDescriptor.java 4 Oct 2002 05:53:00 -0000 1.8 +++ ServiceDescriptor.java 28 Nov 2002 21:27:52 -0000 1.9 @@ -30,29 +30,34 @@ extends FeatureDescriptor { /** + * Constant set of 0 service descriptors. + */ + public static final ServiceDescriptor[] EMPTY_SET = new ServiceDescriptor[ 0 ]; + + /** * The implementationKey for the service. * This usually indicates the name of the service * class. */ - private final String m_implementationKey; + private final String m_type; /** * Construct a service with specified name and Attributes. * - * @param implementationKey the implementationKey of Service + * @param type the type of Service * @param attributes the attributes of service */ - public ServiceDescriptor( final String implementationKey, + public ServiceDescriptor( final String type, final Attribute[] attributes ) { super( attributes ); - if( null == implementationKey ) + if( null == type ) { - throw new NullPointerException( "implementationKey" ); + throw new NullPointerException( "type" ); } - m_implementationKey = implementationKey; + m_type = type; } /** @@ -60,9 +65,9 @@ * * @return the implementationKey of service. */ - public String getImplementationKey() + public String getType() { - return m_implementationKey; + return m_type; } /** @@ -73,7 +78,7 @@ public String toString() { final StringBuffer sb = new StringBuffer(); - sb.append( m_implementationKey ); + sb.append( m_type ); sb.append( attributesToString() ); return sb.toString(); } 1.3 +19 -2 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/ant/FormatEnum.java Index: FormatEnum.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/ant/FormatEnum.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- FormatEnum.java 12 Nov 2002 07:12:16 -0000 1.2 +++ FormatEnum.java 28 Nov 2002 21:27:52 -0000 1.3 @@ -19,8 +19,25 @@ public class FormatEnum extends EnumeratedAttribute { + public int getTypeCode() + { + final String value = super.getValue(); + if( value.equals( "legacy") ) + { + return MetaGenerateTask.LEGACY_TYPE; + } + else if( value.equals( "ser" ) ) + { + return MetaGenerateTask.SER_TYPE; + } + else + { + return MetaGenerateTask.XML_TYPE; + } + } + public String[] getValues() { - return new String[]{"xml", "ser"}; + return new String[]{"xml", "ser", "legacy"}; } } 1.9 +47 -15 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/ant/MetaGenerateTask.java Index: MetaGenerateTask.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/ant/MetaGenerateTask.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- MetaGenerateTask.java 16 Nov 2002 08:01:04 -0000 1.8 +++ MetaGenerateTask.java 28 Nov 2002 21:27:52 -0000 1.9 @@ -18,6 +18,7 @@ import org.apache.avalon.framework.tools.infobuilder.SerializedInfoWriter; import org.apache.avalon.framework.tools.infobuilder.InfoWriter; import org.apache.avalon.framework.tools.infobuilder.XMLInfoWriter; +import org.apache.avalon.framework.tools.infobuilder.LegacyBlockInfoWriter; import org.apache.avalon.framework.tools.qdox.DefaultInfoBuilder; import org.apache.avalon.framework.tools.qdox.LegacyInfoBuilder; import org.apache.avalon.framework.tools.ant.FormatEnum; @@ -31,9 +32,16 @@ * @author <a href="mailto:peter at apache.org">Peter Donald</a> * @version $Revision$ $Date$ */ -public final class MetaGenerateTask +public class MetaGenerateTask extends AbstractQdoxTask { + /* + * A set of type codes for format. + */ + public static final int XML_TYPE = 0; + public static final int SER_TYPE = 1; + public static final int LEGACY_TYPE = 2; + /** * A utility object that writes out info as xml files. */ @@ -45,16 +53,19 @@ private static final InfoWriter c_serWriter = new SerializedInfoWriter(); /** + * A utility object that writes out info as serialized object files. + */ + private static final InfoWriter c_legacyWriter = new LegacyBlockInfoWriter(); + + /** * The destination directory for metadata files. */ private File m_destDir; /** - * Variable that indicates whether the output - * should be done as xml (if true) or as serialized - * objests (if false). + * Variable that indicates the output type. */ - private boolean m_xmlOutput = true; + private int m_format; /** * Variable that indicates whether the output @@ -80,7 +91,7 @@ */ public void setFormat( final FormatEnum format ) { - m_xmlOutput = "xml".equals( format.getValue() ); + m_format = format.getTypeCode(); } /** @@ -151,14 +162,18 @@ */ private String getOutputDescription() { - if( m_xmlOutput ) + if( XML_TYPE == m_format ) { return "xml"; } - else + else if( SER_TYPE == m_format ) { return "serialized objects"; } + else + { + return "legacy xml"; + } } /** @@ -253,14 +268,18 @@ */ private InfoWriter getInfoWriter() { - if( m_xmlOutput ) + if( XML_TYPE == m_format ) { return c_xmlWriter; } - else + else if( SER_TYPE == m_format ) { return c_serWriter; } + else + { + return c_legacyWriter; + } } /** @@ -274,14 +293,18 @@ throws IOException { String filename = - classname.replace( '.', File.separatorChar ) + "-info"; - if( m_xmlOutput ) + classname.replace( '.', File.separatorChar ); + if( XML_TYPE == m_format ) + { + filename += "-info.xml"; + } + else if( SER_TYPE == m_format ) { - filename += ".xml"; + filename += "-info.ser"; } else { - filename += ".ser"; + filename += ".xinfo"; } return new File( m_destDir, filename ).getCanonicalFile(); } @@ -305,4 +328,13 @@ } } + /** + * Return the destination directory in which files are generated. + * + * @return the destination directory in which files are generated. + */ + protected final File getDestDir() + { + return m_destDir; + } } 1.5 +5 -1 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/InfoBuilder.java Index: InfoBuilder.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/InfoBuilder.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- InfoBuilder.java 14 Nov 2002 07:44:30 -0000 1.4 +++ InfoBuilder.java 28 Nov 2002 21:27:52 -0000 1.5 @@ -48,6 +48,10 @@ { setupLogger( m_legacyInfoCreator ); } + if( null != m_legacyInfoCreator ) + { + setupLogger( m_legacyInfoCreator ); + } } /** 1.7 +13 -51 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/LegacyBlockInfoReader.java Index: LegacyBlockInfoReader.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/LegacyBlockInfoReader.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- LegacyBlockInfoReader.java 24 Nov 2002 12:15:26 -0000 1.6 +++ LegacyBlockInfoReader.java 28 Nov 2002 21:27:52 -0000 1.7 @@ -9,7 +9,6 @@ import java.io.InputStream; import java.util.ArrayList; -import java.util.Properties; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.framework.configuration.Configuration; @@ -17,12 +16,10 @@ import org.apache.avalon.framework.info.Attribute; import org.apache.avalon.framework.info.ComponentDescriptor; import org.apache.avalon.framework.info.ComponentInfo; -import org.apache.avalon.framework.info.ContextDescriptor; import org.apache.avalon.framework.info.DependencyDescriptor; -import org.apache.avalon.framework.info.EntryDescriptor; import org.apache.avalon.framework.info.LoggerDescriptor; -import org.apache.avalon.framework.info.ServiceDescriptor; import org.apache.avalon.framework.info.SchemaDescriptor; +import org.apache.avalon.framework.info.ServiceDescriptor; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.xml.sax.InputSource; @@ -119,8 +116,8 @@ return new ComponentInfo( descriptor, services, - new LoggerDescriptor[ 0 ], - buildPhoenixContext(), + LoggerDescriptor.EMPTY_SET, + LegacyUtil.CONTEXT_DESCRIPTOR, dependencies, schema, null ); } @@ -139,27 +136,14 @@ } else { - //TODO: Map phoenix type to uri space when figured out - return new SchemaDescriptor( "", - schemaType, new Attribute[ 0 ] ); + final String schemaUri = + LegacyUtil.translateToSchemaUri( schemaType ); + return new SchemaDescriptor( "", schemaUri, Attribute.EMPTY_SET ); } } /** - * A utility method to build a descriptor for Phoenixs BlockContext - * object, - * - * @return the a descriptor for Phoenixs BlockContext object, - */ - private ContextDescriptor buildPhoenixContext() - { - return new ContextDescriptor( "org.apache.avalon.phoenix.BlockContext", - new EntryDescriptor[ 0 ], - new Attribute[ 0 ] ); - } - - /** * A utility method to build an array of [EMAIL PROTECTED] DependencyDescriptor} * objects from specified configuration and classname. * @@ -182,7 +166,7 @@ dependencies.add( dependency ); } - return (DependencyDescriptor[])dependencies.toArray( new DependencyDescriptor[ 0 ] ); + return (DependencyDescriptor[])dependencies.toArray( DependencyDescriptor.EMPTY_SET ); } /** @@ -224,7 +208,7 @@ return new DependencyDescriptor( key, implementationKey, false, - new Attribute[ 0 ] ); + Attribute.EMPTY_SET ); } /** @@ -253,7 +237,7 @@ services.add( service ); } - return (ServiceDescriptor[])services.toArray( new ServiceDescriptor[ 0 ] ); + return (ServiceDescriptor[])services.toArray( ServiceDescriptor.EMPTY_SET ); } /** @@ -274,16 +258,12 @@ final ArrayList attributeSet = new ArrayList(); if( null != version ) { - final Attribute attribute = - createSimpleAttribute( "avalon", "version", version ); - attributeSet.add( attribute ); + attributeSet.add( LegacyUtil.createVersionAttribute( version ) ); } if( isManagement ) { - final Attribute mxAttribute = - createSimpleAttribute( "phoenix", "mx", "true" ); - attributeSet.add( mxAttribute ); + attributeSet.add( LegacyUtil.MX_ATTRIBUTE ); } final Attribute[] attributes = (Attribute[])attributeSet.toArray( new Attribute[ attributeSet.size() ] ); @@ -304,27 +284,9 @@ { final String version = config.getChild( "version" ).getValue(); final ArrayList attributeSet = new ArrayList(); - final Attribute attribute = createSimpleAttribute( "avalon", "version", version ); - attributeSet.add( attribute ); + attributeSet.add( LegacyUtil.createVersionAttribute( version ) ); final Attribute[] attributes = (Attribute[])attributeSet.toArray( new Attribute[ attributeSet.size() ] ); return new ComponentDescriptor( classname, attributes ); - } - - /** - * Helper method to create simple attributes with one parameter. - * - * @param name the name of the parameter - * @param value the value of the parameter - * @param attributeName the name of the attribute - * @return - */ - private Attribute createSimpleAttribute( final String attributeName, - final String name, - final String value ) - { - final Properties parameters = new Properties(); - parameters.setProperty( name, value ); - return new Attribute( attributeName, parameters ); } } 1.6 +15 -8 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/XMLInfoReader.java Index: XMLInfoReader.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/XMLInfoReader.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- XMLInfoReader.java 24 Nov 2002 12:15:26 -0000 1.5 +++ XMLInfoReader.java 28 Nov 2002 21:27:52 -0000 1.6 @@ -114,7 +114,7 @@ configuration = info.getChild( "parameters-schema", false ); final SchemaDescriptor parametersSchema = buildSchema( configuration ); - + if( getLogger().isDebugEnabled() ) { final String message = @@ -215,7 +215,7 @@ dependencies.add( dependency ); } - return (DependencyDescriptor[])dependencies.toArray( new DependencyDescriptor[ 0 ] ); + return (DependencyDescriptor[])dependencies.toArray( DependencyDescriptor.EMPTY_SET ); } /** @@ -280,7 +280,7 @@ final String type = context.getAttribute( "type", - Context.class.getName() ); + ContextDescriptor.DEFAULT_TYPE ); return new ContextDescriptor( type, entrys, attributes ); } @@ -346,7 +346,7 @@ services.add( service ); } - return (ServiceDescriptor[])services.toArray( new ServiceDescriptor[ 0 ] ); + return (ServiceDescriptor[])services.toArray( ServiceDescriptor.EMPTY_SET ); } /** @@ -360,9 +360,9 @@ private ServiceDescriptor buildService( final Configuration service ) throws ConfigurationException { - final String implementationKey = service.getAttribute( "type" ); + final String type = service.getAttribute( "type" ); final Attribute[] attributes = buildAttributes( service ); - return new ServiceDescriptor( implementationKey, attributes ); + return new ServiceDescriptor( type, attributes ); } /** @@ -399,7 +399,14 @@ { final String name = config.getAttribute( "name" ); final Properties parameters = buildParameters( config ); - return new Attribute( name, parameters ); + if( 0 == parameters.size() ) + { + return new Attribute( name, null ); + } + else + { + return new Attribute( name, parameters ); + } } /** 1.9 +2 -2 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/XMLInfoWriter.java Index: XMLInfoWriter.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/XMLInfoWriter.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- XMLInfoWriter.java 24 Nov 2002 12:15:26 -0000 1.8 +++ XMLInfoWriter.java 28 Nov 2002 21:27:53 -0000 1.9 @@ -294,7 +294,7 @@ { final ServiceDescriptor service = services[ i ]; writer.write( "<service type=\"" ); - writer.write( service.getImplementationKey() ); + writer.write( service.getType() ); final Attribute[] attributes = service.getAttributes(); if( 0 == attributes.length ) { 1.2 +4 -6 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/qdox/AbstractInfoBuilder.java Index: AbstractInfoBuilder.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/qdox/AbstractInfoBuilder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AbstractInfoBuilder.java 16 Nov 2002 05:14:07 -0000 1.1 +++ AbstractInfoBuilder.java 28 Nov 2002 21:27:53 -0000 1.2 @@ -7,11 +7,11 @@ */ package org.apache.avalon.framework.tools.qdox; +import com.thoughtworks.qdox.model.DocletTag; import com.thoughtworks.qdox.model.JavaClass; import com.thoughtworks.qdox.model.JavaMethod; import com.thoughtworks.qdox.model.Type; -import com.thoughtworks.qdox.model.DocletTag; -import org.apache.avalon.framework.info.Attribute; +import org.apache.avalon.framework.info.ContextDescriptor; /** * This is an abstract base class that is used to build a ComponentInfo object @@ -25,8 +25,7 @@ { protected static final String LOGGER_CLASS = "org.apache.avalon.framework.logger.Logger"; - protected static final String CONTEXT_CLASS = - "org.apache.avalon.framework.context.Context"; + protected static final String CONTEXT_CLASS = ContextDescriptor.DEFAULT_TYPE; protected static final String COMPONENT_MANAGER_CLASS = "org.apache.avalon.framework.component.ComponentManager"; protected static final String SERVICE_MANAGER_CLASS = @@ -35,7 +34,6 @@ "org.apache.avalon.framework.configuration.Configuration"; protected static final String PARAMETERS_CLASS = "org.apache.avalon.framework.parameters.Parameters"; - protected static final Attribute[] EMPTY_ATTRIBUTES = new Attribute[ 0 ]; /** * Resolve the specified type. 1.4 +13 -14 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/qdox/DefaultInfoBuilder.java Index: DefaultInfoBuilder.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/qdox/DefaultInfoBuilder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DefaultInfoBuilder.java 24 Nov 2002 12:15:26 -0000 1.3 +++ DefaultInfoBuilder.java 28 Nov 2002 21:27:53 -0000 1.4 @@ -19,6 +19,7 @@ import org.apache.avalon.framework.info.LoggerDescriptor; import org.apache.avalon.framework.info.SchemaDescriptor; import org.apache.avalon.framework.info.ServiceDescriptor; +import org.apache.avalon.framework.info.Attribute; /** * This is a utility class that is used to build a ComponentInfo object @@ -63,7 +64,7 @@ private ComponentDescriptor buildComponent( final JavaClass javaClass ) { final String type = javaClass.getFullyQualifiedName(); - return new ComponentDescriptor( type, EMPTY_ATTRIBUTES ); + return new ComponentDescriptor( type, Attribute.EMPTY_SET ); } /** @@ -81,7 +82,7 @@ final DocletTag tag = tags[ i ]; final String unresolvedType = getNamedParameter( tag, "type" ); final String type = resolveType( javaClass, unresolvedType ); - final ServiceDescriptor service = new ServiceDescriptor( type, EMPTY_ATTRIBUTES ); + final ServiceDescriptor service = new ServiceDescriptor( type, Attribute.EMPTY_SET ); services.add( service ); } return (ServiceDescriptor[])services.toArray( new ServiceDescriptor[ services.size() ] ); @@ -99,7 +100,7 @@ getLifecycleMethod( javaClass, "enableLogging", LOGGER_CLASS ); if( null == method ) { - return new LoggerDescriptor[ 0 ]; + return LoggerDescriptor.EMPTY_SET; } else { @@ -110,7 +111,7 @@ final String name = getNamedParameter( tags[ i ], "name", "" ); final LoggerDescriptor logger = - new LoggerDescriptor( name, EMPTY_ATTRIBUTES ); + new LoggerDescriptor( name, Attribute.EMPTY_SET ); loggers.add( logger ); } return (LoggerDescriptor[])loggers.toArray( new LoggerDescriptor[ loggers.size() ] ); @@ -129,9 +130,7 @@ getLifecycleMethod( javaClass, "contextualize", CONTEXT_CLASS ); if( null == method ) { - return new ContextDescriptor( CONTEXT_CLASS, - new EntryDescriptor[ 0 ], - EMPTY_ATTRIBUTES ); + return ContextDescriptor.EMPTY_CONTEXT; } else { @@ -152,13 +151,13 @@ final String optional = getNamedParameter( tags[ i ], "optional", "false" ); final boolean isOptional = "true".equals( optional ); final EntryDescriptor entry = - new EntryDescriptor( key, entryType, isOptional, EMPTY_ATTRIBUTES ); + new EntryDescriptor( key, entryType, isOptional, Attribute.EMPTY_SET ); entrySet.add( entry ); } final EntryDescriptor[] entrys = (EntryDescriptor[])entrySet.toArray( new EntryDescriptor[ entrySet.size() ] ); - return new ContextDescriptor( type, entrys, EMPTY_ATTRIBUTES ); + return new ContextDescriptor( type, entrys, Attribute.EMPTY_SET ); } } @@ -187,7 +186,7 @@ final String location = getNamedParameter( tag, "location", "" ); final String type = getNamedParameter( tag, "type", "" ); - return new SchemaDescriptor( location, type, EMPTY_ATTRIBUTES ); + return new SchemaDescriptor( location, type, Attribute.EMPTY_SET ); } } @@ -216,7 +215,7 @@ final String location = getNamedParameter( tag, "location", "" ); final String type = getNamedParameter( tag, "type", "" ); - return new SchemaDescriptor( location, type, EMPTY_ATTRIBUTES ); + return new SchemaDescriptor( location, type, Attribute.EMPTY_SET ); } } @@ -240,7 +239,7 @@ if( null == method ) { - return new DependencyDescriptor[ 0 ]; + return DependencyDescriptor.EMPTY_SET; } else { @@ -255,7 +254,7 @@ final String optional = getNamedParameter( tag, "optional", "false" ); final boolean isOptional = "true".equals( optional ); final DependencyDescriptor dependency = - new DependencyDescriptor( key, type, isOptional, EMPTY_ATTRIBUTES ); + new DependencyDescriptor( key, type, isOptional, Attribute.EMPTY_SET ); deps.add( dependency ); } return (DependencyDescriptor[])deps.toArray( new DependencyDescriptor[ deps.size() ] ); 1.3 +12 -25 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/qdox/LegacyInfoBuilder.java Index: LegacyInfoBuilder.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/qdox/LegacyInfoBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- LegacyInfoBuilder.java 24 Nov 2002 12:15:26 -0000 1.2 +++ LegacyInfoBuilder.java 28 Nov 2002 21:27:53 -0000 1.3 @@ -16,10 +16,10 @@ import org.apache.avalon.framework.info.ComponentInfo; import org.apache.avalon.framework.info.ContextDescriptor; import org.apache.avalon.framework.info.DependencyDescriptor; -import org.apache.avalon.framework.info.EntryDescriptor; import org.apache.avalon.framework.info.LoggerDescriptor; import org.apache.avalon.framework.info.SchemaDescriptor; import org.apache.avalon.framework.info.ServiceDescriptor; +import org.apache.avalon.framework.tools.infobuilder.LegacyUtil; /** * Build a ComponentInfo object by interpreting Phoenix style javadoc @@ -42,25 +42,13 @@ { final ComponentDescriptor component = buildComponent( javaClass ); final ServiceDescriptor[] services = buildServices( javaClass ); - final ContextDescriptor context = buildPhoenixContext(); - final LoggerDescriptor[] loggers = new LoggerDescriptor[ 0 ]; + final ContextDescriptor context = LegacyUtil.CONTEXT_DESCRIPTOR; + final LoggerDescriptor[] loggers = LoggerDescriptor.EMPTY_SET; final SchemaDescriptor schema = buildConfigurationSchema( javaClass ); final DependencyDescriptor[] dependencies = buildDependencies( javaClass ); - return new ComponentInfo( component, services, loggers, context, dependencies, schema, null ); - } - - /** - * A utility method to build a descriptor for Phoenixs BlockContext - * object, - * - * @return the a descriptor for Phoenixs BlockContext object, - */ - private ContextDescriptor buildPhoenixContext() - { - return new ContextDescriptor( "org.apache.avalon.phoenix.BlockContext", - new EntryDescriptor[ 0 ], - new Attribute[ 0 ] ); + return new ComponentInfo( component, services, loggers, context, + dependencies, schema, null ); } /** @@ -72,7 +60,7 @@ private ComponentDescriptor buildComponent( final JavaClass javaClass ) { final String type = javaClass.getFullyQualifiedName(); - return new ComponentDescriptor( type, EMPTY_ATTRIBUTES ); + return new ComponentDescriptor( type, Attribute.EMPTY_SET ); } /** @@ -88,7 +76,7 @@ for( int i = 0; i < tags.length; i++ ) { final String type = getNamedParameter( tags[ i ], "name" ); - final ServiceDescriptor service = new ServiceDescriptor( type, EMPTY_ATTRIBUTES ); + final ServiceDescriptor service = new ServiceDescriptor( type, Attribute.EMPTY_SET ); services.add( service ); } return (ServiceDescriptor[])services.toArray( new ServiceDescriptor[ services.size() ] ); @@ -116,9 +104,8 @@ return null; } final String type = getNamedParameter( tag, "type", "" ); - //TODO: Translate type into a uri type string - return new SchemaDescriptor( - "", type, EMPTY_ATTRIBUTES ); + final String schemaUri = LegacyUtil.translateToSchemaUri( type ); + return new SchemaDescriptor( "", schemaUri, Attribute.EMPTY_SET ); } /** @@ -141,7 +128,7 @@ if( null == method ) { - return new DependencyDescriptor[ 0 ]; + return DependencyDescriptor.EMPTY_SET; } else { @@ -154,7 +141,7 @@ final String type = resolveType( javaClass, unresolvedType ); final String key = getNamedParameter( tag, "role", type ); final DependencyDescriptor dependency = - new DependencyDescriptor( key, type, false, EMPTY_ATTRIBUTES ); + new DependencyDescriptor( key, type, false, Attribute.EMPTY_SET ); deps.add( dependency ); } return (DependencyDescriptor[])deps.toArray( new DependencyDescriptor[ deps.size() ] ); 1.6 +2 -2 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/verifier/InfoVerifier.java Index: InfoVerifier.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/verifier/InfoVerifier.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- InfoVerifier.java 24 Nov 2002 12:15:26 -0000 1.5 +++ InfoVerifier.java 28 Nov 2002 21:27:53 -0000 1.6 @@ -279,7 +279,7 @@ final Class[] classes = new Class[ services.length ]; for( int i = 0; i < services.length; i++ ) { - final String classname = services[ i ].getImplementationKey(); + final String classname = services[ i ].getType(); try { classes[ i ] = classLoader.loadClass( classname ); 1.8 +3 -5 jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/InfoAssert.java Index: InfoAssert.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/InfoAssert.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- InfoAssert.java 24 Nov 2002 12:15:26 -0000 1.7 +++ InfoAssert.java 28 Nov 2002 21:27:53 -0000 1.8 @@ -26,8 +26,6 @@ */ public class InfoAssert { - public static final Attribute[] EMPTY_ATTRIBUTES = new Attribute[ 0 ]; - public static void assertEqualStructure( final String message, final ComponentInfo expected, final ComponentInfo actual ) @@ -148,8 +146,8 @@ final ServiceDescriptor actual ) { Assert.assertEquals( message + ".type", - expected.getImplementationKey(), - actual.getImplementationKey() ); + expected.getType(), + actual.getType() ); assertEqualAttributes( message + ".attributes", expected.getAttributes(), actual.getAttributes() ); 1.18 +28 -22 jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/InfoBuilderTestCase.java Index: InfoBuilderTestCase.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/InfoBuilderTestCase.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- InfoBuilderTestCase.java 24 Nov 2002 12:15:26 -0000 1.17 +++ InfoBuilderTestCase.java 28 Nov 2002 21:27:53 -0000 1.18 @@ -36,6 +36,8 @@ import org.apache.avalon.framework.tools.infobuilder.SerializedInfoWriter; import org.apache.avalon.framework.tools.infobuilder.XMLInfoReader; import org.apache.avalon.framework.tools.infobuilder.XMLInfoWriter; +import org.apache.avalon.framework.tools.infobuilder.LegacyBlockInfoReader; +import org.apache.avalon.framework.tools.infobuilder.LegacyBlockInfoWriter; import org.apache.avalon.framework.tools.qdox.DefaultInfoBuilder; import org.apache.avalon.framework.tools.qdox.LegacyInfoBuilder; @@ -105,23 +107,18 @@ private ComponentInfo createComponentInfoWithParameters() { final ComponentDescriptor component = - new ComponentDescriptor( "org.realityforge.Component1", InfoAssert.EMPTY_ATTRIBUTES ); - - final ContextDescriptor context = - new ContextDescriptor( "org.apache.avalon.framework.context.Context", - new EntryDescriptor[ 0 ], - InfoAssert.EMPTY_ATTRIBUTES ); + new ComponentDescriptor( "org.realityforge.Component1", Attribute.EMPTY_SET ); final SchemaDescriptor schema = new SchemaDescriptor( "", "", - InfoAssert.EMPTY_ATTRIBUTES ); + Attribute.EMPTY_SET ); return new ComponentInfo( component, - new ServiceDescriptor[0], - new LoggerDescriptor[ 0 ], - context, - new DependencyDescriptor[0], + ServiceDescriptor.EMPTY_SET, + LoggerDescriptor.EMPTY_SET, + ContextDescriptor.EMPTY_CONTEXT, + DependencyDescriptor.EMPTY_SET, null, schema ); } @@ -142,6 +139,15 @@ new XMLInfoReader() ); } + public void testWriteLegacyXMLComponent1() + throws Exception + { + final ComponentInfo info = loadComponentInfo( COMPONENT2 ); + runWriteReadTest( info, + new LegacyBlockInfoWriter(), + new LegacyBlockInfoReader() ); + } + public void testQDoxScan() throws Exception { @@ -200,8 +206,8 @@ final FileInputStream inputStream = new FileInputStream( output ); final ComponentInfo actual = reader.createComponentInfo( implementationKey, inputStream ); inputStream.close(); - output.deleteOnExit(); - output.delete(); + //output.deleteOnExit(); + //output.delete(); InfoAssert.assertEqualInfos( " Dummy ComponentInfo written out and read back " + "in again should be equal", @@ -212,22 +218,22 @@ private ComponentInfo createDummyComponentInfo() { final ComponentDescriptor component = - new ComponentDescriptor( "org.realityforge.Component1", InfoAssert.EMPTY_ATTRIBUTES ); + new ComponentDescriptor( "org.realityforge.Component1", Attribute.EMPTY_SET ); - final LoggerDescriptor logger1 = new LoggerDescriptor( "", InfoAssert.EMPTY_ATTRIBUTES ); - final LoggerDescriptor logger2 = new LoggerDescriptor( "audit", InfoAssert.EMPTY_ATTRIBUTES ); + final LoggerDescriptor logger1 = new LoggerDescriptor( "", Attribute.EMPTY_SET ); + final LoggerDescriptor logger2 = new LoggerDescriptor( "audit", Attribute.EMPTY_SET ); final LoggerDescriptor[] loggers = new LoggerDescriptor[]{logger1, logger2}; final EntryDescriptor entry1 = new EntryDescriptor( "mbean", "javax.jmx.MBeanServer", false, - InfoAssert.EMPTY_ATTRIBUTES ); + Attribute.EMPTY_SET ); final EntryDescriptor[] entrys = new EntryDescriptor[]{entry1}; final ContextDescriptor context = new ContextDescriptor( "org.apache.avalon.phoenix.BlockContext", entrys, - InfoAssert.EMPTY_ATTRIBUTES ); + Attribute.EMPTY_SET ); final ServiceDescriptor service1 = createServiceDescriptor(); @@ -236,19 +242,19 @@ new DependencyDescriptor( "org.realityforge.Service2", "org.realityforge.Service2", true, - InfoAssert.EMPTY_ATTRIBUTES ); + Attribute.EMPTY_SET ); final DependencyDescriptor dependency2 = new DependencyDescriptor( "foo", "org.realityforge.Service3", false, - InfoAssert.EMPTY_ATTRIBUTES ); + Attribute.EMPTY_SET ); final DependencyDescriptor[] deps = new DependencyDescriptor[]{dependency1, dependency2}; final SchemaDescriptor schema = new SchemaDescriptor( "", "http://relaxng.org/ns/structure/1.0", - InfoAssert.EMPTY_ATTRIBUTES ); + Attribute.EMPTY_SET ); return new ComponentInfo( component, services, loggers, context, deps, schema, null ); 1.3 +1 -1 jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/data/QDoxLegacyComponent1-info.xml Index: QDoxLegacyComponent1-info.xml =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/data/QDoxLegacyComponent1-info.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- QDoxLegacyComponent1-info.xml 24 Nov 2002 12:15:27 -0000 1.2 +++ QDoxLegacyComponent1-info.xml 28 Nov 2002 21:27:53 -0000 1.3 @@ -20,6 +20,6 @@ <dependency type="org.apache.avalon.framework.tools.infobuilder.test.data.otherpkg.Service2"/> </dependencies> - <configuration-schema type="rlng"/> + <configuration-schema type="http://relaxng.org/ns/structure/1.0"/> </component-info> 1.3 +2 -2 jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/data/QDoxLegacyComponent1.java Index: QDoxLegacyComponent1.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/data/QDoxLegacyComponent1.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- QDoxLegacyComponent1.java 16 Nov 2002 07:59:00 -0000 1.2 +++ QDoxLegacyComponent1.java 28 Nov 2002 21:27:53 -0000 1.3 @@ -43,7 +43,7 @@ } /** - * @phoenix:configuration-schema type="rlng" + * @phoenix:configuration-schema type="relax-ng" */ public void configure( Configuration configuration ) throws ConfigurationException 1.2 +1 -1 jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/data/component2.xinfo Index: component2.xinfo =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/data/component2.xinfo,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- component2.xinfo 4 Oct 2002 06:10:35 -0000 1.1 +++ component2.xinfo 28 Nov 2002 21:27:53 -0000 1.2 @@ -7,7 +7,7 @@ <!-- section to describe block --> <block> <version>1.0</version> - <schema-type>rlng</schema-type> + <schema-type>relax-ng</schema-type> </block> <!-- services that are offered by this block --> 1.4 +3 -5 jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/data/component3-info.xml Index: component3-info.xml =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/data/component3-info.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- component3-info.xml 24 Nov 2002 12:15:27 -0000 1.3 +++ component3-info.xml 28 Nov 2002 21:27:53 -0000 1.4 @@ -7,7 +7,7 @@ <!-- This component should be identical to the one loaded out of component2 blockinfo --> <component type="org.apache.avalon.framework.tools.infobuilder.test.data.component3"> - <attribute name="avalon"> + <attribute name="phoenix:version"> <param name="version" value="1.0"/> </attribute> </component> @@ -17,9 +17,7 @@ <services> <service type="org.apache.avalon.cornerstone.services.scheduler.TimeScheduler"/> <service type="org.apache.avalon.cornerstone.services.scheduler.TimeScheduler2"> - <attribute name="phoenix"> - <param name="mx" value="true"/> - </attribute> + <attribute name="phoenix:mx"/> </service> </services> @@ -27,6 +25,6 @@ <dependency type="org.apache.avalon.cornerstone.services.threads.ThreadManager"/> </dependencies> - <configuration-schema type="rlng"/> + <configuration-schema type="http://relaxng.org/ns/structure/1.0"/> </component-info> 1.16 +3 -3 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/SourceResolverImpl.java Index: SourceResolverImpl.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/SourceResolverImpl.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- SourceResolverImpl.java 12 Nov 2002 04:04:53 -0000 1.15 +++ SourceResolverImpl.java 28 Nov 2002 21:27:53 -0000 1.16 @@ -149,11 +149,11 @@ ClassLoader loader = Thread.currentThread().getContextClassLoader(); if( loader == null ) { - loader = this.getClass().getClassLoader(); + loader = getClass().getClassLoader(); } try { - this.m_urlSourceClass = loader.loadClass( urlSourceClassName ); + m_urlSourceClass = loader.loadClass( urlSourceClassName ); } catch( ClassNotFoundException cnfe ) {
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>