avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/xdoclet AvalonTagHandler.java componentinfo.xdt
Date Thu, 27 Jun 2002 04:50:36 GMT
donaldp     2002/06/26 21:50:36

  Modified:    containerkit/src/java/org/apache/excalibur/containerkit/xdoclet
                        AvalonTagHandler.java componentinfo.xdt
  Log:
  Updated taghandler so that it will allow you to use the short name of type in the "interface"
attribute on dependency and service tags.
  
  So if you import a class (org.apache.baz.FooService) then you can refer to it as "FooService"
and it will be resolved. This resolution will not work for inner classes and if you specify
a type with a dot in it then it will assume that you have fully specified type.
  
  Revision  Changes    Path
  1.2       +68 -1     jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/xdoclet/AvalonTagHandler.java
  
  Index: AvalonTagHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/xdoclet/AvalonTagHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AvalonTagHandler.java	27 Jun 2002 03:30:50 -0000	1.1
  +++ AvalonTagHandler.java	27 Jun 2002 04:50:36 -0000	1.2
  @@ -12,6 +12,7 @@
   import xdoclet.tags.AbstractProgramElementTagsHandler;
   import xjavadoc.XTag;
   import xjavadoc.XClass;
  +import xjavadoc.XPackage;
   
   /**
    * A simpler tag handler to walk over attributes in a class.
  @@ -33,6 +34,19 @@
           setCurrentClassTag( xTag );
       }
   
  +    public void setCurrentAttribute( final Properties atributes )
  +        throws XDocletException
  +    {
  +        final String attribute = atributes.getProperty( "name", "" );
  +        c_attribute = attribute;
  +    }
  +
  +    public void unsetCurrentAttribute()
  +        throws XDocletException
  +    {
  +        c_attribute = null;
  +    }
  +
       /**
        * Iterates over the attributes of current tag.
        */
  @@ -52,6 +66,59 @@
       public String attributeName()
       {
           return c_attribute;
  +    }
  +
  +    public String attributeValueAsType()
  +    {
  +        final String typeName = attributeValue();
  +        if( -1 != typeName.indexOf( '.' ) )
  +        {
  +            //User has specified full
  +            return typeName;
  +        }
  +        else
  +        {
  +            final XClass[] classes = getCurrentClass().containingPackage().classes();
  +            XClass xClass =  findClass( typeName, classes );
  +            if( null != xClass )
  +            {
  +                return xClass.qualifiedName();
  +            }
  +
  +            xClass = findClass( typeName, getCurrentClass().importedClasses() );
  +            if( null != xClass )
  +            {
  +                return xClass.qualifiedName();
  +            }
  +
  +            final XPackage[] xPackages = getCurrentClass().importedPackages();
  +            for( int i = 0; i < xPackages.length; i++ )
  +            {
  +                xClass = findClass( typeName, xPackages[ i ].classes() );
  +                if( null != xClass )
  +                {
  +                    return xClass.qualifiedName();
  +                }
  +            }
  +            return typeName;
  +        }
  +    }
  +
  +    private XClass findClass( final String name,
  +                              final XClass[] classes )
  +    {
  +        XClass xClass = null;
  +        for( int i = 0; i < classes.length; i++ )
  +        {
  +            final XClass singleImport = classes[ i ];
  +            final String classname = singleImport.name();
  +            if( classname.equals( name ) )
  +            {
  +                xClass = singleImport;
  +                break;
  +            }
  +        }
  +        return xClass;
       }
   
       public String attributeValue()
  
  
  
  1.2       +15 -5     jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/xdoclet/componentinfo.xdt
  
  Index: componentinfo.xdt
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/xdoclet/componentinfo.xdt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- componentinfo.xdt	27 Jun 2002 03:30:50 -0000	1.1
  +++ componentinfo.xdt	27 Jun 2002 04:50:36 -0000	1.2
  @@ -26,7 +26,9 @@
     <services>
       <XDtClass:forAllClassTags tagName="avalon.service">
       <service>
  -      <service-ref name="<XDtClass:classTagValue tagName="avalon.service" paramName="interface"/>"<XDtClass:ifHasClassTag
tagName="avalon.service" paramName="version"> version="<XDtClass:classTagValue tagName="avalon.service"
paramName="version"/>"</XDtClass:ifHasClassTag>/>
  +      <XDtAvalon:setCurrentAttribute name="interface"/>
  +      <service-ref name="<XDtAvalon:attributeValueAsType/>"<XDtClass:ifHasClassTag
tagName="avalon.service" paramName="version"> version="<XDtClass:classTagValue tagName="avalon.service"
paramName="version"/>"</XDtClass:ifHasClassTag>/>
  +      <XDtAvalon:unsetCurrentAttribute/>
         <attributes>
         <XDtAvalon:forAllAttributes>
           <XDtAvalon:ifAttributeNameNotEquals value="interface">
  @@ -47,15 +49,19 @@
         <XDtMethod:setCurrentMethod name="compose"
                                     parameters="org.apache.avalon.framework.component.ComponentManager">
           <XDtMethod:forAllMethodTags tagName="avalon.dependency">
  -    <dependency>
  +    <dependency<XDtMethod:ifHasMethodTag tagName="avalon.dependency" paramName="optional">
optional="<XDtMethod:methodTagValue tagName="avalon.dependency" paramName="optional"/>"</XDtMethod:ifHasMethodTag>>
         <XDtMethod:ifHasMethodTag tagName="avalon.dependency" paramName="role"><role><XDtMethod:methodTagValue
tagName="avalon.dependency" paramName="role"/></role></XDtMethod:ifHasMethodTag>
  -      <service name="<XDtMethod:methodTagValue tagName="avalon.dependency" paramName="interface"/>"<XDtMethod:ifHasMethodTag
tagName="avalon.dependency" paramName="version"> version="<XDtMethod:methodTagValue
tagName="avalon.dependency" paramName="version"/>"</XDtMethod:ifHasMethodTag>/>
  +      <XDtAvalon:setCurrentAttribute name="interface"/>
  +      <service-ref name="<XDtAvalon:attributeValueAsType/>"<XDtMethod:ifHasMethodTag
tagName="avalon.dependency" paramName="version"> version="<XDtMethod:methodTagValue
tagName="avalon.dependency" paramName="version"/>"</XDtMethod:ifHasMethodTag>/>
  +      <XDtAvalon:unsetCurrentAttribute/>
         <attributes>
         <XDtAvalon:forAllAttributes>
           <XDtAvalon:ifAttributeNameNotEquals value="interface">
             <XDtAvalon:ifAttributeNameNotEquals value="version">
               <XDtAvalon:ifAttributeNameNotEquals value="role">
  +              <XDtAvalon:ifAttributeNameNotEquals value="optional">
           <attribute name="<XDtAvalon:attributeName/>" value="<XDtAvalon:attributeValue/>"/>
  +              </XDtAvalon:ifAttributeNameNotEquals>
               </XDtAvalon:ifAttributeNameNotEquals>
             </XDtAvalon:ifAttributeNameNotEquals>
           </XDtAvalon:ifAttributeNameNotEquals>
  @@ -70,15 +76,19 @@
         <XDtMethod:setCurrentMethod name="service"
                                     parameters="org.apache.avalon.framework.service.ServiceManager">
           <XDtMethod:forAllMethodTags tagName="avalon.dependency">
  -    <dependency>
  +    <dependency<XDtMethod:ifHasMethodTag tagName="avalon.dependency" paramName="optional">
optional="<XDtMethod:methodTagValue tagName="avalon.dependency" paramName="optional"/>"</XDtMethod:ifHasMethodTag>>
         <XDtMethod:ifHasMethodTag tagName="avalon.dependency" paramName="role"><role><XDtMethod:methodTagValue
tagName="avalon.dependency" paramName="role"/></role></XDtMethod:ifHasMethodTag>
  -      <service name="<XDtMethod:methodTagValue tagName="avalon.dependency" paramName="interface"/>"<XDtMethod:ifHasMethodTag
tagName="avalon.dependency" paramName="version"> version="<XDtMethod:methodTagValue
tagName="avalon.dependency" paramName="version"/>"</XDtMethod:ifHasMethodTag>/>
  +      <XDtAvalon:setCurrentAttribute name="interface"/>
  +      <service-ref name="<XDtAvalon:attributeValueAsType/>"<XDtMethod:ifHasMethodTag
tagName="avalon.dependency" paramName="version"> version="<XDtMethod:methodTagValue
tagName="avalon.dependency" paramName="version"/>"</XDtMethod:ifHasMethodTag>/>
  +      <XDtAvalon:unsetCurrentAttribute/>
         <attributes>
         <XDtAvalon:forAllAttributes>
           <XDtAvalon:ifAttributeNameNotEquals value="interface">
             <XDtAvalon:ifAttributeNameNotEquals value="version">
               <XDtAvalon:ifAttributeNameNotEquals value="role">
  +              <XDtAvalon:ifAttributeNameNotEquals value="optional">
           <attribute name="<XDtAvalon:attributeName/>" value="<XDtAvalon:attributeValue/>"/>
  +              </XDtAvalon:ifAttributeNameNotEquals>
               </XDtAvalon:ifAttributeNameNotEquals>
             </XDtAvalon:ifAttributeNameNotEquals>
           </XDtAvalon:ifAttributeNameNotEquals>
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message