You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by do...@apache.org on 2002/09/13 17:42:13 UTC
cvs commit: jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/xdoclet PTag.java AvalonTagHandler.java componentinfo.xdt
donaldp 2002/09/13 08:42:13
Modified: info/src/java/org/apache/avalon/framework/info
ComponentDescriptor.java ComponentInfo.java
ContextDescriptor.java DependencyDescriptor.java
EntryDescriptor.java FeatureDescriptor.java
LoggerDescriptor.java ServiceDescriptor.java
TagDescriptor.java package.html
info/src/java/org/apache/avalon/framework/tools/infobuilder
ComponentInfoBuilder.java XMLInfoCreator.java
componentinfo.dtd
info/src/java/org/apache/avalon/framework/tools/xdoclet
AvalonTagHandler.java componentinfo.xdt
Added: info/src/java/org/apache/avalon/framework/info
ServiceInfo.java
info/src/java/org/apache/avalon/framework/tools/xdoclet
PTag.java
Log:
Upgrade the codebase from using
<attribute name="a:x" value="y"/>
To using
<tag name="a">
<param name="x" value="y"/>
</tag>
This is the same model that MS uses and it allows far superior validation and control of attributes/attribute groups.
Revision Changes Path
1.5 +9 -11 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/ComponentDescriptor.java
Index: ComponentDescriptor.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/ComponentDescriptor.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ComponentDescriptor.java 8 Sep 2002 03:35:20 -0000 1.4
+++ ComponentDescriptor.java 13 Sep 2002 15:42:12 -0000 1.5
@@ -7,8 +7,6 @@
*/
package org.apache.avalon.framework.info;
-import java.util.Properties;
-
/**
* This class is used to provide explicit information to assembler
* and administrator about the Component. It includes information
@@ -20,10 +18,10 @@
* </ul>
*
* <p>The ComponentDescriptor also includes an arbitrary set
- * of attributes about component. Usually these are container
- * specific attributes that can store arbitrary information.
- * The attributes should be stored with keys based on package
- * name of container. ie You could use the following</p>
+ * of tags about the component. Usually these are container
+ * specific tags that store information relevent to a particular
+ * requirement. The tag names should be stored with keys based
+ * on package name of container. ie You could use the following</p>
*
* <pre>
* public class CocoonKeys
@@ -41,8 +39,8 @@
* ...
*
* ComponentDescriptor cd = ...;
- * String lifestyle = cd.getAttribute( LIFESTYLE, "single-threaded" );
- * String scope = cd.getAttribute( SCOPE, null );
+ * TagDescriptor lifestyle = cd.getTag( LIFESTYLE );
+ * TagDescriptor scope = cd.getTag( SCOPE );
* </pre>
*
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
@@ -65,9 +63,9 @@
public ComponentDescriptor( final String name,
final String implementationKey,
- final Properties attributes )
+ final TagDescriptor[] tags )
{
- super( attributes );
+ super( tags );
if( null == name )
{
throw new NullPointerException( "name" );
1.4 +1 -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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ComponentInfo.java 8 Sep 2002 04:44:36 -0000 1.3
+++ ComponentInfo.java 13 Sep 2002 15:42:12 -0000 1.4
@@ -8,7 +8,6 @@
package org.apache.avalon.framework.info;
import java.io.Serializable;
-import org.apache.avalon.framework.info.ContextDescriptor;
/**
* This class contains the meta information about a particular
1.7 +4 -6 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ContextDescriptor.java 13 Sep 2002 12:00:50 -0000 1.6
+++ ContextDescriptor.java 13 Sep 2002 15:42:12 -0000 1.7
@@ -7,8 +7,6 @@
*/
package org.apache.avalon.framework.info;
-import java.util.Properties;
-
/**
* A descriptor describing the Context that the component
* is passed to describe information about Runtime environment
@@ -21,7 +19,7 @@
* </ul>
*
* <p>Associated with each Context is a set of arbitrary
- * attributes that can be used to store extra information
+ * tags that can be used to store extra information
* about Context requirements.</p>
*
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
@@ -50,9 +48,9 @@
*/
public ContextDescriptor( final String type,
final EntryDescriptor[] entrys,
- final Properties attributes )
+ final TagDescriptor[] tags )
{
- super( attributes );
+ super( tags );
if( null == type )
{
1.6 +6 -8 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DependencyDescriptor.java 8 Sep 2002 04:57:05 -0000 1.5
+++ DependencyDescriptor.java 13 Sep 2002 15:42:12 -0000 1.6
@@ -7,8 +7,6 @@
*/
package org.apache.avalon.framework.info;
-import java.util.Properties;
-
/**
* A descriptor that describes dependency information for
* a particular Component. This class contains information
@@ -19,11 +17,11 @@
* </ul>
*
* <p>Also associated with each dependency is a set of arbitrary
- * attributes that can be used to store extra information
+ * tags that can be used to store extra information
* about dependency. See {@link ComponentDescriptor} for example
- * of how to declare the container specific attributes.</p>
+ * of how to declare the container specific tags.</p>
*
- * <p>Possible uses for the attributes are to declare container
+ * <p>Possible uses for the tags are to declare container
* specific constraints of component. For example a dependency on
* a Corba ORB may also require that the Corba ORB contain the
* TimeServer and PersistenceStateService at initialization. Or it
@@ -58,9 +56,9 @@
public DependencyDescriptor( final String key,
final String service,
final boolean optional,
- final Properties attributes )
+ final TagDescriptor[] tags )
{
- super( attributes );
+ super( tags );
if( null == key )
{
1.4 +6 -7 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- EntryDescriptor.java 9 Sep 2002 12:37:37 -0000 1.3
+++ EntryDescriptor.java 13 Sep 2002 15:42:12 -0000 1.4
@@ -8,7 +8,6 @@
package org.apache.avalon.framework.info;
import java.io.Serializable;
-import java.util.Properties;
/**
* A descriptor that describes a value that must be placed
@@ -21,12 +20,12 @@
*
* <p>See the <a href="doc-files/entries.html">Entries</a> document
* for a list of widely recognized entry values and a recomended
- * naming scheme for other attributes.</p>
+ * naming scheme for other entrys.</p>
*
* <p>Also associated with each entry is a set of arbitrary
- * attributes that can be used to store extra information
+ * tags that can be used to store extra information
* about entry. See {@link ComponentDescriptor} for example
- * of how to declare the container specific attributes.</p>
+ * of how to declare the container specific tags.</p>
*
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
* @version $Revision$ $Date$
@@ -56,9 +55,9 @@
public EntryDescriptor( final String key,
final String type,
final boolean optional,
- final Properties attributes )
+ final TagDescriptor[] tags )
{
- super( attributes );
+ super( tags );
if( null == key )
{
1.3 +30 -48 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/FeatureDescriptor.java
Index: FeatureDescriptor.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/FeatureDescriptor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FeatureDescriptor.java 31 Aug 2002 13:54:55 -0000 1.2
+++ FeatureDescriptor.java 13 Sep 2002 15:42:12 -0000 1.3
@@ -7,16 +7,14 @@
*/
package org.apache.avalon.framework.info;
-import java.util.Properties;
import java.io.Serializable;
/**
* This is the Abstract class for all feature descriptors.
- * Every descriptor has the capability of adding attributes
- * of some kind. These attributes can then be interpreted by
- * the container. The interpretation of specific attributes
- * on specific features will be further defined by further
- * attribute specification documents.
+ * Every descriptor has the capability of adding Tags
+ * of some kind. These Tags can then be interpreted by
+ * the container. The meaning of the specific tags will
+ * be defined by future specification documents.
*
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
* @version $Revision$ $Date$
@@ -24,67 +22,51 @@
public abstract class FeatureDescriptor
implements Serializable
{
- private static final String[] EMPTY_SET = new String[0];
-
/**
- * The arbitrary set of attributes associated with Component.
+ * The arbitrary set of tags associated with Component.
*/
- private final Properties m_attributes;
-
- protected FeatureDescriptor( final Properties attributes )
- {
- m_attributes = attributes;
- }
+ private final TagDescriptor[] m_tags;
/**
- * Return the attribute for specified key.
+ * Create a FeatureDescriptor with specific set of tags.
*
- * @return the attribute for specified key.
+ * @param tags the tags
*/
- public String getAttribute( final String key )
+ protected FeatureDescriptor( final TagDescriptor[] tags )
{
- if( null == m_attributes )
+ if( null == tags )
{
- return null;
- }
- else
- {
- return m_attributes.getProperty( key );
+ throw new NullPointerException( "tags" );
}
+
+ m_tags = tags;
}
/**
- * Return the attribute for specified key.
+ * Return the tags associated with descriptor.
*
- * @return the attribute for specified key.
+ * @return the tags associated with descriptor.
*/
- public String getAttribute( final String key,
- final String defaultValue )
+ public TagDescriptor[] getTags()
{
- if( null == m_attributes )
- {
- return defaultValue;
- }
- else
- {
- return m_attributes.getProperty( key, defaultValue );
- }
+ return m_tags;
}
/**
- * Returns the set of attribute names available under this descriptor.
- *
- * @return an array of the properties names held by the descriptor.
- */
- public String[] getAttributeNames()
+ * Return the tag with specified name.
+ *
+ * @return the tag with specified name.
+ */
+ public TagDescriptor getTag( final String name )
{
- if( null == m_attributes )
- {
- return EMPTY_SET;
- }
- else
+ for( int i = 0; i < m_tags.length; i++ )
{
- return (String[]) m_attributes.keySet().toArray( EMPTY_SET );
+ final TagDescriptor tag = m_tags[ i ];
+ if( tag.getName().equals( name ) )
+ {
+ return tag;
+ }
}
+ return null;
}
}
1.4 +4 -6 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LoggerDescriptor.java 31 Aug 2002 23:21:23 -0000 1.3
+++ LoggerDescriptor.java 13 Sep 2002 15:42:12 -0000 1.4
@@ -7,8 +7,6 @@
*/
package org.apache.avalon.framework.info;
-import java.util.Properties;
-
/**
* A descriptor describing the Loggers that the Component
* will use. The name of each Logger is relative to the
@@ -16,7 +14,7 @@
* The name "", designates the root logger.
*
* <p>Associated with each Logger is a set of arbitrary
- * attributes that can be used to store extra information
+ * tags that can be used to store extra information
* about Logger requirements.</p>
*
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
@@ -33,9 +31,9 @@
* @exception NullPointerException if name argument is null
*/
public LoggerDescriptor( final String name,
- final Properties attributes )
+ final TagDescriptor[] tags )
{
- super( attributes );
+ super( tags );
if( null == name )
{
throw new NullPointerException( "name" );
1.5 +11 -13 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServiceDescriptor.java 8 Sep 2002 04:57:05 -0000 1.4
+++ ServiceDescriptor.java 13 Sep 2002 15:42:12 -0000 1.5
@@ -7,22 +7,20 @@
*/
package org.apache.avalon.framework.info;
-import java.util.Properties;
-
/**
* This descriptor defines the type of service offerend or required
* by a component. The type corresponds to the class name of the
* class/interface implemented by component.
*
* <p>Also associated with each service is a set of arbitrary
- * attributes that can be used to store extra information
- * about service. See {@link org.apache.avalon.framework.info.ComponentDescriptor} for example
- * of how to declare the container specific attributes.</p>
+ * tags that can be used to store extra information
+ * about service. See {@link ComponentDescriptor} for example
+ * of how to declare the container specific tags.</p>
*
- * <p>Possible uses for the attributes are to declare a service
+ * <p>Possible uses for the tags are to declare a service
* as "stateless", "pass-by-value", "remotable" or even to attach
- * attributes such as security or transaction constraints. These
- * attributes are container specific and should not be relied
+ * tags such as security or transaction constraints. These
+ * tags are container specific and should not be relied
* upon to work in all containers.</p>
*
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
@@ -39,15 +37,15 @@
private final String m_implementationKey;
/**
- * Construct a service with specified name and attributes.
+ * Construct a service with specified name and tags.
*
* @param implementationKey the implementationKey of Service
- * @param attributes the attributes of service
+ * @param tags the tags of service
*/
public ServiceDescriptor( final String implementationKey,
- final Properties attributes )
+ final TagDescriptor[] tags )
{
- super( attributes );
+ super( tags );
if( null == implementationKey )
{
1.2 +2 -2 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/TagDescriptor.java
Index: TagDescriptor.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/TagDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TagDescriptor.java 13 Sep 2002 12:23:41 -0000 1.1
+++ TagDescriptor.java 13 Sep 2002 15:42:12 -0000 1.2
@@ -32,7 +32,7 @@
private final String m_name;
/**
- * The arbitrary set of attributes associated with Component.
+ * The arbitrary set of parameters associated with the tag.
*/
private final Properties m_parameters;
1.2 +22 -22 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/package.html
Index: package.html
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/package.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- package.html 31 Aug 2002 08:17:00 -0000 1.1
+++ package.html 13 Sep 2002 15:42:12 -0000 1.2
@@ -10,51 +10,51 @@
declaration of the services implemented by a component type, the service
dependecies that a component type has on other components, and lastly,
general information of the component including its name, implementation
-version and related attributes.<p>
+version and related features.<p>
<h3>Package Structure (UML)</h3>
<p><img src=doc-files/uml.gif border=0></p>
<p>The info package allows many of the descriptors to contain
-extra attributes. These attributes offer mechanisms via which
-the container can determine learn extra information about a
+extra tags. These tags offer mechanisms via which
+the container can determine extra information about a
component. This information may or may not determine the behaviour
of the container towards the component.</p>
-<p>For example a component that declared an attribute "mx:enabled=true"
+<p>For example a component that declared a tag "avalon.mx enabled=true"
on a service it provided would indicate to the container that the service
is part of the management interface of the component. However it is up to
-the container to recognize the significance of the attribute and if supported
-the attribute should be acted.</p>
+the container to recognize the significance of the tag and if supported
+the tag should be acted.</p>
<p>To ease the development of containers and components this document will
-document a set of common attributes that are common across containers.
+document a set of common tags that are common across containers.
However it should be noted that any container provider is allowed to create
-a set of new attributes that the particular container is capable of handling.
-It should be noted that these attributes will usually be in a container
+a set of new tags that the particular container is capable of handling.
+It should be noted that these tags will usually be in a container
specific namespace.</p>
-<p>The name of each attribute is made up of two components, the namespace
-and the local name of the attribute. The namespace is separated from the
-local name by either a ";" character or a "." character. So the attribute
-name "mx:enabled" is equivelent to "mx.enabled" as far as the container is
+<p>The name of each tag is made up of two components, the namespace
+and the local name of the tags. The namespace is separated from the
+local name by either a ";" character or a "." character. So the tags
+name "avalon:mx" is equivelent to "avalon.mx" as far as the container is
concerned.</p>
<p>Any container is welcome to create their own namespace in which they can
-define any attributes they see fit. The namespace should be equal to the
+define any tags they see fit. The namespace should be equal to the
shortname of the container. For example if the
<a href="http://jakarta.apache.org/avalon/phoenix">Phoenix</a> container wanted
-to add extra attributes it would use a namespace "phoenix" while the Fortress
+to add extra tags it would use a namespace "phoenix" while the Fortress
container would use the "fortress" namespace.</p>
-<p>Besides the namespace separator the attribute name may only be made up of
+<p>Besides the namespace separator the tags name may only be made up of
alphanumeric values, '_' and '-'. Neither the local name or the namespace may
being with a numeric value.</p>
-<p>The following is a table of standard attributes. It is not necessary that
-a container support all these attributes (or any of them) however if the
+<p>The following is a table of standard tags. It is not necessary that
+a container support all these tags (or any of them) however if the
container does support such notions it is recomended that they use the
-following attributes to enable interoperability between containers.</p>
+following tags to enable interoperability between containers.</p>
<h3>Avalon namespace</h3>
@@ -81,7 +81,7 @@
<td>true or false</td>
<td>false</td>
<td>
- This attribute can be applied at either the service or the component level.
+ This tags can be applied at either the service or the component level.
It indicated that the particular artefact is stateless. This means that the
order of the method calls will not have an effect on the results of call.
If applied at the component level it indicates that all services are
@@ -94,7 +94,7 @@
<td>true or false</td>
<td>false</td>
<td>
- This attribute can be applied at the service level. If true, it indicates
+ This tags can be applied at the service level. If true, it indicates
that the parameters passed to methods of service are not modified by the
service.
</td>
@@ -105,7 +105,7 @@
<td>comma separated list of features</td>
<td>false</td>
<td>
- This attribute can be applied at the service level. If true, it indicates
+ This tags can be applied at the service level. If true, it indicates
that the parameters passed to methods of service are not modified by the
service.
</td>
1.1 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/ServiceInfo.java
Index: ServiceInfo.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.framework.info;
import java.io.Serializable;
/**
* This class contains the meta information about a particular
* Service. It describes;
*
* <ul>
* <li>Human presentable meta data such as name, version, description etc
* useful when assembling the system.</li>
* </ul>
*
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2002/09/13 15:42:12 $
*/
public class ServiceInfo
implements Serializable
{
private final ServiceDescriptor m_service;
/**
* Basic constructor that takes as parameters all parts.
*/
public ServiceInfo( final ServiceDescriptor service )
{
if( null == service )
{
throw new NullPointerException( "service" );
}
m_service = service;
}
/**
* Return the Service descriptor.
*
* @return the Service descriptor.
*/
public ServiceDescriptor getServiceDescriptor()
{
return m_service;
}
}
1.2 +2 -2 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/ComponentInfoBuilder.java
Index: ComponentInfoBuilder.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/ComponentInfoBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ComponentInfoBuilder.java 31 Aug 2002 08:17:01 -0000 1.1
+++ ComponentInfoBuilder.java 13 Sep 2002 15:42:12 -0000 1.2
@@ -16,7 +16,7 @@
import org.apache.avalon.framework.info.ComponentInfo;
/**
- * A ComponentInfoBuilder is responsible for building {@link org.apache.avalon.framework.info.ComponentInfo}
+ * A ComponentInfoBuilder is responsible for building {@link ComponentInfo}
* objects from Configuration objects. The format for Configuration object
* is specified in the <a href="package-summary.html#external">package summary</a>.
*
1.8 +66 -33 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/XMLInfoCreator.java
Index: XMLInfoCreator.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/XMLInfoCreator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XMLInfoCreator.java 9 Sep 2002 12:37:37 -0000 1.7
+++ XMLInfoCreator.java 13 Sep 2002 15:42:12 -0000 1.8
@@ -15,7 +15,6 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.info.ComponentDescriptor;
import org.apache.avalon.framework.info.ComponentInfo;
import org.apache.avalon.framework.info.ContextDescriptor;
@@ -23,6 +22,8 @@
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.TagDescriptor;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.xml.sax.InputSource;
/**
@@ -156,9 +157,9 @@
private LoggerDescriptor buildLogger( Configuration logger )
throws ConfigurationException
{
- final Properties attributes = buildAttributes( logger.getChild( "attributes" ) );
final String name = logger.getAttribute( "name", "" );
- return new LoggerDescriptor( name, attributes );
+ final TagDescriptor[] tags = buildTags( logger );
+ return new LoggerDescriptor( name, tags );
}
/**
@@ -205,8 +206,7 @@
final boolean optional =
dependency.getAttributeAsBoolean( "optional", false );
- final Properties attributes =
- buildAttributes( dependency.getChild( "attributes" ) );
+ final TagDescriptor[] tags = buildTags( dependency );
String key = dependency.getAttribute( "key", null );
@@ -229,7 +229,7 @@
}
}
- return new DependencyDescriptor( key, implementationKey, optional, attributes );
+ return new DependencyDescriptor( key, implementationKey, optional, tags );
}
/**
@@ -246,14 +246,13 @@
final EntryDescriptor[] entrys =
buildEntrys( context.getChildren( "entry" ) );
- final Properties attributes =
- buildAttributes( context.getChild( "attributes" ) );
+ final TagDescriptor[] tags = buildTags( context );
final String type =
context.getAttribute( "type",
Context.class.getName() );
- return new ContextDescriptor( type, entrys, attributes );
+ return new ContextDescriptor( type, entrys, tags );
}
/**
@@ -292,10 +291,9 @@
final String type = config.getAttribute( "type" );
final boolean optional =
config.getAttributeAsBoolean( "optional", false );
- final Properties attributes =
- buildAttributes( config.getChild( "attributes" ) );
+ final TagDescriptor[] tags = buildTags( config );
- return new EntryDescriptor( key, type, optional, attributes );
+ return new EntryDescriptor( key, type, optional, tags );
}
/**
@@ -333,48 +331,83 @@
throws ConfigurationException
{
final String implementationKey = service.getAttribute( "type" );
- final Properties attributes =
- buildAttributes( service.getChild( "attributes" ) );
- return new ServiceDescriptor( implementationKey, attributes );
+ final TagDescriptor[] tags = buildTags( service );
+ return new ServiceDescriptor( implementationKey, tags );
}
/**
- * Build up a list of attributes from specific config tree.
+ * Build up a list of tags from specific config tree.
*
- * @param config the attributes config
- * @return the Properties object representing attributes
+ * @param config the tags config
+ * @return the set of tags
*/
- private Properties buildAttributes( final Configuration config )
+ private TagDescriptor[] buildTags( final Configuration config )
throws ConfigurationException
{
- final Properties attributes = new Properties();
- final Configuration[] children = config.getChildren( "attribute" );
+ final ArrayList tags = new ArrayList();
+
+ final Configuration[] tagConfigs = config.getChildren( "tag" );
+ for( int i = 0; i < tagConfigs.length; i++ )
+ {
+ final Configuration tagConfig = tagConfigs[ i ];
+ final TagDescriptor tag = buildTag( tagConfig );
+ tags.add( tag );
+ }
+
+ return (TagDescriptor[])tags.toArray( new TagDescriptor[ tags.size() ] );
+ }
+
+ /**
+ * Build a tag from a specific configuration.
+ *
+ * @param config the configuration to build tag from
+ * @return the new Tag
+ * @throws ConfigurationException if unable to build tag due to malformed xml
+ */
+ private TagDescriptor buildTag( Configuration config )
+ throws ConfigurationException
+ {
+ final String name = config.getAttribute( "name" );
+ final Properties parameters = buildParameters( config );
+ return new TagDescriptor( name, parameters );
+ }
+
+ /**
+ * Build up a list of parameters from specific config tree.
+ *
+ * @param config the parameters config
+ * @return the Properties object representing parameters
+ */
+ private Properties buildParameters( final Configuration config )
+ throws ConfigurationException
+ {
+ final Properties parameters = new Properties();
+ final Configuration[] children = config.getChildren( "param" );
for( int i = 0; i < children.length; i++ )
{
- Configuration child = children[ i ];
- final String key = child.getAttribute( "key" );
+ final Configuration child = children[ i ];
+ final String key = child.getAttribute( "name" );
final String value = child.getAttribute( "value" );
- attributes.setProperty( key, value );
+ parameters.setProperty( key, value );
}
- return attributes;
+ return parameters;
}
/**
* A utility method to build a {@link ComponentDescriptor}
* object from specified configuraiton data and classname.
*
- * @param component the Component Configuration
+ * @param config the Component Configuration
* @return the created ComponentDescriptor
* @throws ConfigurationException if an error occurs
*/
- private ComponentDescriptor buildComponentDescriptor( final Configuration component )
+ private ComponentDescriptor buildComponentDescriptor( final Configuration config )
throws ConfigurationException
{
- final String name = component.getAttribute( "name", null );
- final String type = component.getAttribute( "type" );
- final Properties attributes =
- buildAttributes( component.getChild( "attributes" ) );
+ final String name = config.getAttribute( "name", null );
+ final String type = config.getAttribute( "type" );
+ final TagDescriptor[] tags = buildTags( config );
- return new ComponentDescriptor( name, type, attributes );
+ return new ComponentDescriptor( name, type, tags );
}
}
1.9 +15 -21 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/componentinfo.dtd
Index: componentinfo.dtd
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/infobuilder/componentinfo.dtd,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- componentinfo.dtd 9 Sep 2002 12:43:39 -0000 1.8
+++ componentinfo.dtd 13 Sep 2002 15:42:12 -0000 1.9
@@ -40,7 +40,7 @@
containing alphanumeric characters, '.', '_' and starting
with a letter.
-->
-<!ELEMENT component (attributes?)>
+<!ELEMENT component (tags?)>
<!ATTLIST component name CDATA #REQUIRED
type CDATA #REQUIRED >
@@ -48,9 +48,9 @@
The logger element defines the loggers that are available to component.
The element has one attribute specifying name of Logger. It contains:
-attributes Optional attributes about logger
+tags Optional tags about logger
-->
-<!ELEMENT logger (attributes?) >
+<!ELEMENT logger (tag*) >
<!ATTLIST logger name CDATA #IMPLIED >
<!--
@@ -59,24 +59,23 @@
It contains:
entrys Key value pairs that component uses
-attributes Optional attributes about service
+tags Optional tags about service
-->
-<!ELEMENT context (entry*,attributes?) >
+<!ELEMENT context (entry*,tag*) >
<!ATTLIST context type CDATA #IMPLIED >
<!--
The service element defines a service that the component
can provide to other component.
-Its Attributes:
type the name of the service. This is usually equal to the class
name of the interface that defines the service.
It contains:
-attributes Optional attributes about service
+tag Optional tags about service
-->
-<!ELEMENT service (attributes?) >
+<!ELEMENT service (tag*) >
<!ATTLIST service type CDATA #REQUIRED >
<!--
@@ -86,7 +85,7 @@
key the key used to lookup service. If not provided it defaults
to the value specified in the name attribute of service element
-->
-<!ELEMENT dependency (attributes?) >
+<!ELEMENT dependency (tag*) >
<!ATTLIST dependency
key CDATA #IMPLIED
type CDATA #REQUIRED
@@ -110,21 +109,16 @@
<!ELEMENT dependencies (dependency*)>
<!--
-The attributes element contains a list of attributes for feature.
--->
-<!ELEMENT attributes (attribute*)>
-
-<!--
-The attribute element defines an attribute (an opaque key-value pair for a feature).
+The param element defines an parameter to a tag.
It defines:
-key the key for attribute.
+name the name of attribute.
value the value of attribute.
-->
-<!ELEMENT attribute (#PCDATA) >
- <!ATTLIST attribute
- key CDATA #REQUIRED
- value CDATA #IMPLIED
+<!ELEMENT param (#PCDATA) >
+ <!ATTLIST param
+ name CDATA #REQUIRED
+ value CDATA #REQUIRED
>
<!--
@@ -135,7 +129,7 @@
value the value of entry.
optional is entry optional
-->
-<!ELEMENT entry (attributes?) >
+<!ELEMENT entry (tag*) >
<!ATTLIST entry
key CDATA #REQUIRED
type CDATA #REQUIRED
1.2 +148 -1 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/xdoclet/AvalonTagHandler.java
Index: AvalonTagHandler.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/xdoclet/AvalonTagHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AvalonTagHandler.java 31 Aug 2002 08:17:01 -0000 1.1
+++ AvalonTagHandler.java 13 Sep 2002 15:42:12 -0000 1.2
@@ -8,7 +8,9 @@
package org.apache.avalon.framework.tools.xdoclet;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
import org.apache.commons.logging.Log;
@@ -33,6 +35,8 @@
private static final String CONTEXT_METHOD =
"contextualize(org.apache.avalon.framework.context.Context)";
private static String c_attribute;
+ private static PTag c_pTag;
+ private static String c_pTagParam;
public void forAllServices( final String template )
throws XDocletException
@@ -72,6 +76,18 @@
}
}
+ public void setMethodTag( final Properties attributes )
+ throws XDocletException
+ {
+ final String tagName = attributes.getProperty( "tag" );
+ if( null == tagName )
+ {
+ return;
+ }
+ final XTag tag = getCurrentMethod().getDoc().getTag( tagName );
+ setCurrentMethodTag( tag );
+ }
+
public void forContextDef( final String template )
throws XDocletException
{
@@ -82,6 +98,137 @@
setCurrentMethod( method );
generate( template );
}
+ }
+
+ public void forAllClassTags( final String template,
+ final Properties attributes )
+ throws XDocletException
+ {
+ final XClass currentClass = getCurrentClass();
+ final Collection tags = currentClass.getDoc().getTags();
+ final String[] skips = getSkips( attributes );
+ final Iterator iterator = tags.iterator();
+ while( iterator.hasNext() )
+ {
+ final XTag tag = (XTag)iterator.next();
+ if( !matchesSkip( tag.getName(), skips ) )
+ {
+ setCurrentClassTag( tag );
+ generate( template );
+ }
+ }
+ }
+
+ public void forAllMethodTags( final String template,
+ final Properties attributes )
+ throws XDocletException
+ {
+ final XMethod currentMethod = getCurrentMethod();
+ final Collection tags = currentMethod.getDoc().getTags();
+ final String[] skips = getSkips( attributes );
+ final Iterator iterator = tags.iterator();
+ while( iterator.hasNext() )
+ {
+ final XTag tag = (XTag)iterator.next();
+ if( !matchesSkip( tag.getName(), skips ) )
+ {
+ setCurrentMethodTag( tag );
+ generate( template );
+ }
+ }
+ }
+
+ public void forAllClassPTags( final String template,
+ final Properties attributes )
+ throws XDocletException
+ {
+ forAllPTags( template, getCurrentClassTag() );
+ }
+
+ public void forAllMethodPTags( final String template,
+ final Properties attributes )
+ throws XDocletException
+ {
+ final XTag currentMethodTag = getCurrentMethodTag();
+ forAllPTags( template, currentMethodTag );
+ }
+
+ private void forAllPTags( final String template,
+ final XTag tag )
+ throws XDocletException
+ {
+ final Map pTags = buildPTags( tag );
+ final Iterator iterator = pTags.keySet().iterator();
+ while( iterator.hasNext() )
+ {
+ final String name = (String)iterator.next();
+ c_pTag = (PTag)pTags.get( name );
+ generate( template );
+ }
+ c_pTag = null;
+ }
+
+ public String getPTagName()
+ {
+ return c_pTag.getName();
+ }
+
+ public void forAllPTagParams( final String template )
+ throws XDocletException
+ {
+ final Properties parameters = c_pTag.getParameters();
+ final Iterator iterator = parameters.keySet().iterator();
+ while( iterator.hasNext() )
+ {
+ c_pTagParam = (String)iterator.next();
+ generate( template );
+ }
+ c_pTagParam = null;
+ }
+
+ public String getPTagParamName()
+ {
+ return c_pTagParam;
+ }
+
+ public String getPTagParamValue()
+ {
+ return c_pTag.getParameters().getProperty( c_pTagParam );
+ }
+
+ private Map buildPTags( final XTag tag )
+ {
+ final HashMap pTags = new HashMap();
+
+ final Collection names = tag.getAttributeNames();
+ final Iterator iterator = names.iterator();
+ while( iterator.hasNext() )
+ {
+ final String paramName = (String)iterator.next();
+ final int index = paramName.indexOf( '.' );
+ if( -1 == index )
+ {
+ continue;
+ }
+
+ final String namespace = paramName.substring( 0, index );
+ PTag pTag = (PTag)pTags.get( namespace );
+ if( null == pTag )
+ {
+ pTag = new PTag( namespace, new Properties() );
+ pTags.put( namespace, pTag );
+ }
+
+ final String key = paramName.substring( index + 1 );
+ final String value = tag.getAttributeValue( paramName );
+ pTag.getParameters().setProperty( key, value );
+ }
+ return pTags;
+ }
+
+ public String getClassTagName()
+ {
+ return getCurrentClassTag().getName();
}
public void forAllClassAttributes( final String template,
1.6 +37 -22 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/xdoclet/componentinfo.xdt
Index: componentinfo.xdt
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/xdoclet/componentinfo.xdt,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- componentinfo.xdt 13 Sep 2002 08:41:55 -0000 1.5
+++ componentinfo.xdt 13 Sep 2002 15:42:12 -0000 1.6
@@ -9,26 +9,37 @@
<!-- section to describe Component -->
<component<XDtClass:ifHasClassTag tagName="avalon.component" paramName="name"> name="<XDtClass:classTagValue tagName="avalon.component" paramName="name"/>"</XDtClass:ifHasClassTag> type="<XDtClass:fullClassName/>">
- <attributes>
- <XDtAvalon:forAllClassAttributes tag="avalon.component" skip="interface,version,role">
- <attribute key="<XDtAvalon:getAttributeName/>" value="<XDtAvalon:getClassAttributeValue/>"/>
+ <XDtAvalon:forAllClassTags skip="avalon.component,avalon.service">
+ <tag name="<XDtAvalon:getClassTagName/>">
+ <XDtAvalon:forAllClassAttributes>
+ <param name="<XDtAvalon:getAttributeName/>" value="<XDtAvalon:getClassAttributeValue/>"/>
</XDtAvalon:forAllClassAttributes>
- </attributes>
+ </tag>
+ </XDtAvalon:forAllClassTags>
</component>
<!-- Context in which this Component operates -->
<XDtAvalon:forContextDef>
<context<XDtMethod:ifHasMethodTag tagName="avalon.context" paramName="type"> type="<XDtAvalon:getMethodAttributeValueAsType tag="avalon.context" name="type"/>"</XDtMethod:ifHasMethodTag>>
<XDtMethod:forAllMethodTags tagName="avalon.entry">
- <entry key="<XDtMethod:methodTagValue tagName="avalon.entry" paramName="key"/>" type="<XDtAvalon:getMethodAttributeValueAsType name="type"/>"<XDtMethod:ifHasMethodTag tagName="avalon.entry" paramName="isOptional"> optional="<XDtMethod:methodTagValue tagName="avalon.entry" paramName="isOptional"/>"</XDtMethod:ifHasMethodTag>/>
+ <entry key="<XDtMethod:methodTagValue tagName="avalon.entry" paramName="key"/>" type="<XDtAvalon:getMethodAttributeValueAsType name="type"/>"<XDtMethod:ifHasMethodTag tagName="avalon.entry" paramName="isOptional"> optional="<XDtMethod:methodTagValue tagName="avalon.entry" paramName="isOptional"/>"</XDtMethod:ifHasMethodTag>>
+ <XDtAvalon:forAllMethodPTags>
+ <tag name="<XDtAvalon:getPTagName/>">
+ <XDtAvalon:forAllPTagParams>
+ <param name="<XDtAvalon:getPTagParamName/>" value="<XDtAvalon:getPTagParamValue/>"/>
+ </XDtAvalon:forAllPTagParams>
+ </tag>
+ </XDtAvalon:forAllMethodPTags>
+ </entry>
</XDtMethod:forAllMethodTags>
- <XDtMethod:ifHasMethodTag tagName="avalon.context">
- <attributes>
- <XDtAvalon:forAllMethodAttributes tag="avalon.context" skip="type">
- <attribute key="<XDtAvalon:getAttributeName/>" value="<XDtAvalon:getMethodAttributeValue/>"/>
- </XDtAvalon:forAllMethodAttributes>
- </attributes>
- </XDtMethod:ifHasMethodTag>
+ <XDtAvalon:setMethodTag tag="avalon.context" />
+ <XDtAvalon:forAllMethodPTags>
+ <tag name="<XDtAvalon:getPTagName/>">
+ <XDtAvalon:forAllPTagParams>
+ <param name="<XDtAvalon:getPTagParamName/>" value="<XDtAvalon:getPTagParamValue/>"/>
+ </XDtAvalon:forAllPTagParams>
+ </tag>
+ </XDtAvalon:forAllMethodPTags>
</context>
</XDtAvalon:forContextDef>
@@ -36,11 +47,13 @@
<services>
<XDtAvalon:forAllServices>
<service type="<XDtAvalon:getClassAttributeValueAsType name="interface"/>">
- <attributes>
- <XDtAvalon:forAllClassAttributes skip="interface,version,role">
- <attribute key="<XDtAvalon:getAttributeName/>" value="<XDtAvalon:getClassAttributeValue/>"/>
- </XDtAvalon:forAllClassAttributes>
- </attributes>
+ <XDtAvalon:forAllClassPTags>
+ <tag name="<XDtAvalon:getPTagName/>">
+ <XDtAvalon:forAllPTagParams>
+ <param name="<XDtAvalon:getPTagParamName/>" value="<XDtAvalon:getPTagParamValue/>"/>
+ </XDtAvalon:forAllPTagParams>
+ </tag>
+ </XDtAvalon:forAllClassPTags>
</service>
</XDtAvalon:forAllServices>
</services>
@@ -53,12 +66,14 @@
role"/>"</XDtMethod:ifHasMethodTag> type="<XDtAvalon:getMethodAttributeValueAsType name="interface"/>"<XDtMethod:ifHasMethodTag
tagName="avalon.dependency" paramName="optional"> optional="<XDtMethod:methodTagValue
tagName="avalon.dependency" paramName="optional"/>"</XDtMethod:ifHasMethodTag>>
- <attributes>
- <XDtAvalon:forAllMethodAttributes skip="interface,version,role,optional">
- <attribute key="<XDtAvalon:getAttributeName/>" value="<XDtAvalon:getMethodAttributeValue/>"/>
- </XDtAvalon:forAllMethodAttributes>
- </attributes>
</dependency>
+ <XDtAvalon:forAllMethodPTags>
+ <tag name="<XDtAvalon:getPTagName/>">
+ <XDtAvalon:forAllPTagParams>
+ <param name="<XDtAvalon:getPTagParamName/>" value="<XDtAvalon:getPTagParamValue/>"/>
+ </XDtAvalon:forAllPTagParams>
+ </tag>
+ </XDtAvalon:forAllMethodPTags>
</XDtAvalon:forAllDeps>
</dependencies>
1.1 jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/xdoclet/PTag.java
Index: PTag.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.framework.tools.xdoclet;
import java.util.Properties;
/**
* A Pseudo-Tag used when translating Javadoc tags into
* ComponentInfo tags.
*
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2002/09/13 15:42:12 $
*/
class PTag
{
private final String m_name;
private final Properties m_parameters;
public PTag( String name, Properties parameters )
{
if( null == name )
{
throw new NullPointerException( "name" );
}
if( null == parameters )
{
throw new NullPointerException( "parameters" );
}
m_name = name;
m_parameters = parameters;
}
public String getName()
{
return m_name;
}
public Properties getParameters()
{
return m_parameters;
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>