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/info/src/java/org/apache/avalon/framework/tools/generator QDoxInfoBuilder.java
Date Tue, 12 Nov 2002 06:47:29 GMT
donaldp     2002/11/11 22:47:29

  Modified:    info/src/java/org/apache/avalon/framework/tools/generator
                        QDoxInfoBuilder.java
  Log:
  Fix a number of bugs. The most significant of which is that
  parameter values must be stripped of " and ' marks. Also
  needed to use correct classname for ServiceManager etc
  
  Revision  Changes    Path
  1.2       +80 -69    jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/generator/QDoxInfoBuilder.java
  
  Index: QDoxInfoBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/tools/generator/QDoxInfoBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- QDoxInfoBuilder.java	12 Nov 2002 03:48:34 -0000	1.1
  +++ QDoxInfoBuilder.java	12 Nov 2002 06:47:29 -0000	1.2
  @@ -36,7 +36,7 @@
       private static final String COMPONENT_MANAGER_CLASS =
           "org.apache.avalon.framework.component.ComponentManager";
       private static final String SERVICE_MANAGER_CLASS =
  -        "org.apache.avalon.framework.component.ServiceManager";
  +        "org.apache.avalon.framework.service.ServiceManager";
   
       private static final Attribute[] EMPTY_ATTRIBUTES = new Attribute[ 0 ];
   
  @@ -58,66 +58,15 @@
       }
   
       /**
  -     * Build the set of dependency descriptors for specified class.
  -     *
  -     * @param javaClass the class
  -     * @return the set of dependency descriptors
  -     */
  -    private DependencyDescriptor[] buildDependencies( final JavaClass javaClass )
  -    {
  -        JavaMethod method =
  -            getLifecycleMethod( javaClass, "compose", COMPONENT_MANAGER_CLASS );
  -
  -        //If no compose then try for a service method ...
  -        if( null == method )
  -        {
  -            method =
  -                getLifecycleMethod( javaClass, "service", SERVICE_MANAGER_CLASS );
  -        }
  -
  -        if( null == method )
  -        {
  -            return new DependencyDescriptor[ 0 ];
  -        }
  -        else
  -        {
  -            final ArrayList deps = new ArrayList();
  -            final DocletTag[] tags = method.getTagsByName( "avalon.dependency" );
  -            for( int i = 0; i < tags.length; i++ )
  -            {
  -                final DocletTag tag = tags[ i ];
  -                final String unresolvedType = getNamedParameter( tag, "interface" );
  -                final String type = resolveType( javaClass, unresolvedType );
  -                final String key = getNamedParameter( tag, "key", type );
  -                final String optional = getNamedParameter( tag, "optional", "false" );
  -                final boolean isOptional = "true".equals( optional );
  -                final DependencyDescriptor dependency =
  -                    new DependencyDescriptor( key, type, isOptional, EMPTY_ATTRIBUTES );
  -                deps.add( dependency );
  -            }
  -            return (DependencyDescriptor[])deps.toArray( new DependencyDescriptor[ deps.size()
] );
  -        }
  -    }
  -
  -    /**
  -     * Build the set of service descriptors for specified class.
  +     * Build the component descriptor for specified class.
        *
        * @param javaClass the class
  -     * @return the set of service descriptors
  +     * @return the component descriptor
        */
  -    private ServiceDescriptor[] buildServices( final JavaClass javaClass )
  +    private ComponentDescriptor buildComponentDescriptor( final JavaClass javaClass )
       {
  -        final ArrayList services = new ArrayList();
  -        final DocletTag[] tags = javaClass.getTagsByName( "avalon.service" );
  -        for( int i = 0; i < tags.length; i++ )
  -        {
  -            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
);
  -            services.add( service );
  -        }
  -        return (ServiceDescriptor[])services.toArray( new ServiceDescriptor[ services.size()
] );
  +        final String type = javaClass.getFullyQualifiedName();
  +        return new ComponentDescriptor( type, EMPTY_ATTRIBUTES );
       }
   
       /**
  @@ -137,7 +86,7 @@
           else
           {
               final ArrayList loggers = new ArrayList();
  -            final DocletTag[] tags = method.getTagsByName( "avalon.loggers" );
  +            final DocletTag[] tags = method.getTagsByName( "avalon.logger" );
               for( int i = 0; i < tags.length; i++ )
               {
                   final String name =
  @@ -172,7 +121,8 @@
               final DocletTag tag = method.getTagByName( "avalon.context" );
               if( null != tag && null != tag.getNamedParameter( "type" ) )
               {
  -                type = resolveType( javaClass, tag.getNamedParameter( "type" ) );
  +                final String value = getNamedParameter( tag, "type" );
  +                type = resolveType( javaClass, value );
               }
   
               final ArrayList entrySet = new ArrayList();
  @@ -195,15 +145,66 @@
       }
   
       /**
  -     * Build the component descriptor for specified class.
  +     * Build the set of service descriptors for specified class.
        *
        * @param javaClass the class
  -     * @return the component descriptor
  +     * @return the set of service descriptors
        */
  -    private ComponentDescriptor buildComponentDescriptor( final JavaClass javaClass )
  +    private ServiceDescriptor[] buildServices( final JavaClass javaClass )
       {
  -        final String type = javaClass.getFullyQualifiedName();
  -        return new ComponentDescriptor( type, EMPTY_ATTRIBUTES );
  +        final ArrayList services = new ArrayList();
  +        final DocletTag[] tags = javaClass.getTagsByName( "avalon.service" );
  +        for( int i = 0; i < tags.length; i++ )
  +        {
  +            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
);
  +            services.add( service );
  +        }
  +        return (ServiceDescriptor[])services.toArray( new ServiceDescriptor[ services.size()
] );
  +    }
  +
  +    /**
  +     * Build the set of dependency descriptors for specified class.
  +     *
  +     * @param javaClass the class
  +     * @return the set of dependency descriptors
  +     */
  +    private DependencyDescriptor[] buildDependencies( final JavaClass javaClass )
  +    {
  +        JavaMethod method =
  +            getLifecycleMethod( javaClass, "compose", COMPONENT_MANAGER_CLASS );
  +
  +        //If no compose then try for a service method ...
  +        if( null == method )
  +        {
  +            method =
  +                getLifecycleMethod( javaClass, "service", SERVICE_MANAGER_CLASS );
  +        }
  +
  +        if( null == method )
  +        {
  +            return new DependencyDescriptor[ 0 ];
  +        }
  +        else
  +        {
  +            final ArrayList deps = new ArrayList();
  +            final DocletTag[] tags = method.getTagsByName( "avalon.dependency" );
  +            for( int i = 0; i < tags.length; i++ )
  +            {
  +                final DocletTag tag = tags[ i ];
  +                final String unresolvedType = getNamedParameter( tag, "type" );
  +                final String type = resolveType( javaClass, unresolvedType );
  +                final String key = getNamedParameter( tag, "key", type );
  +                final String optional = getNamedParameter( tag, "optional", "false" );
  +                final boolean isOptional = "true".equals( optional );
  +                final DependencyDescriptor dependency =
  +                    new DependencyDescriptor( key, type, isOptional, EMPTY_ATTRIBUTES );
  +                deps.add( dependency );
  +            }
  +            return (DependencyDescriptor[])deps.toArray( new DependencyDescriptor[ deps.size()
] );
  +        }
       }
   
       /**
  @@ -215,7 +216,8 @@
        * @param type the unresolved type
        * @return the resolved type
        */
  -    private String resolveType( final JavaClass javaClass, final String type )
  +    private String resolveType( final JavaClass javaClass,
  +                                final String type )
       {
           return javaClass.getParentSource().resolveType( type );
       }
  @@ -260,11 +262,20 @@
                                         final String name,
                                         final String defaultValue )
       {
  -        final String value = tag.getNamedParameter( name );
  +        String value = tag.getNamedParameter( name );
           if( null == value )
           {
               return defaultValue;
           }
  +        value = value.trim();
  +        if( value.startsWith( "\"" ) || value.startsWith( "'" ) )
  +        {
  +            value = value.substring( 1 );
  +        }
  +        if( value.endsWith( "\"" ) || value.endsWith( "'" ) )
  +        {
  +            value = value.substring( 0, value.length() - 1 );
  +        }
           return value;
       }
   
  @@ -276,9 +287,9 @@
        * @param name the name of parameter
        * @return the value of named parameter
        */
  -    private static String getNamedParameter( final DocletTag tag, final String name )
  +    private String getNamedParameter( final DocletTag tag, final String name )
       {
  -        final String value = tag.getNamedParameter( name );
  +        final String value = getNamedParameter( tag, name, null );
           if( null == value )
           {
               final String message =
  
  
  

--
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