avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/tools/metagenerate/test IntegrationTestCase.java
Date Sun, 20 Oct 2002 11:55:38 GMT
hammant     2002/10/20 04:55:38

  Modified:    src/java/org/apache/avalon/phoenix/tools/metagenerate
                        MetaGenerateQdoxTask.java XinfoFactory.java
               src/test/org/apache/avalon/phoenix/tools/metagenerate/test
                        IntegrationTestCase.java
  Log:
  Inheritance now works.  Tests too.
  
  Revision  Changes    Path
  1.4       +2 -1      jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/metagenerate/MetaGenerateQdoxTask.java
  
  Index: MetaGenerateQdoxTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/metagenerate/MetaGenerateQdoxTask.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MetaGenerateQdoxTask.java	20 Oct 2002 10:25:50 -0000	1.3
  +++ MetaGenerateQdoxTask.java	20 Oct 2002 11:55:38 -0000	1.4
  @@ -73,7 +73,8 @@
               DocletTag block = javaClass.getTagByName("phoenix:block");
               if (block != null)
               {
  -                XinfoFactory factory = new XinfoFactory(m_destDir, javaClass, m_inheritance);
  +                XinfoFactory factory = new XinfoFactory(m_destDir, javaClass,
  +                        allClasses, m_inheritance);
                   factory.generate();
               }
               DocletTag topic = javaClass.getTagByName("phoenix:mx-topic");
  
  
  
  1.6       +42 -31    jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/metagenerate/XinfoFactory.java
  
  Index: XinfoFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/metagenerate/XinfoFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XinfoFactory.java	20 Oct 2002 10:25:51 -0000	1.5
  +++ XinfoFactory.java	20 Oct 2002 11:55:38 -0000	1.6
  @@ -15,6 +15,7 @@
   import java.io.IOException;
   import java.util.HashMap;
   import java.util.Iterator;
  +import java.util.ArrayList;
   
   /**
    * A Xinfo Factory
  @@ -24,6 +25,7 @@
   {
       private JavaClass m_javaClass;
       private File m_destDir;
  +    private ArrayList m_allClasses;
       private HashMap m_services = new HashMap();
       private HashMap m_dependencies = new HashMap();
       private boolean m_inheritance;
  @@ -34,11 +36,13 @@
        * @param destDir
        * @param javaClass
        */
  -    public XinfoFactory( File destDir, JavaClass javaClass, boolean inheritance )
  +    public XinfoFactory( File destDir, JavaClass javaClass, ArrayList allClasses,
  +                         boolean inheritance )
       {
           m_javaClass = javaClass;
           m_destDir = destDir;
           m_inheritance = inheritance;
  +        m_allClasses = allClasses;
       }
   
       /**
  @@ -64,7 +68,7 @@
   
           xinfo.writeEndOfManagementSection();
   
  -        processServiceMethod( xinfo );
  +        processServiceMethod( xinfo, m_inheritance );
           xinfo.writeFooter();
           xinfo.close();
   
  @@ -88,8 +92,7 @@
                   String serviceName = service.getNamedParameter( "name" );
                   m_services.put( serviceName, service );
               }
  -            //javaClass = getParentClass(javaClass);  // Bug in QDox?
  -            javaClass = null;
  +            javaClass = getParentClass(javaClass);
           }
   
   
  @@ -109,20 +112,15 @@
       private JavaClass getParentClass(JavaClass javaClass)
       {
           String parentClassName = javaClass.getSuperClass().getValue();
  -        System.out.println("--> p " + parentClassName);
  -        JavaClass[] parentSourceClasses = javaClass.getParentSource().getClasses();
  -        javaClass = null;
  -        for (int i = 0; i < parentSourceClasses.length; i++)
  -        {
  -            JavaClass parentClass = parentSourceClasses[i];
  -            System.out.println("--> p2 " + parentClass.getFullyQualifiedName());
  -            if (parentClassName.equals(parentClass.getFullyQualifiedName()))
  +        for (int i = 0; i < m_allClasses.size(); i++)
  +        {
  +            JavaClass jClass = (JavaClass) m_allClasses.get(i);
  +            if (jClass.getFullyQualifiedName().equals(parentClassName))
               {
  -                javaClass = parentClass;
  +                return jClass;
               }
  -
           }
  -        return javaClass;
  +        return null;
       }
   
       /**
  @@ -144,28 +142,41 @@
        * @param xinfo The xinfo helper
        * @throws IOException If a problem
        */
  -    private void processServiceMethod( XinfoHelper xinfo ) throws IOException
  +    private void processServiceMethod( XinfoHelper xinfo, boolean inheritance ) throws
IOException
       {
  -        JavaMethod[] methods = m_javaClass.getMethods();
  -        for( int j = 0; j < methods.length; j++ )
  +        JavaClass javaClass = m_javaClass;
  +        while (m_javaClass == javaClass || (javaClass != null && inheritance))
           {
  -            // dependencies
  -
  -            JavaMethod method = methods[ j ];
  -            if( method.getName().equals( "service" )
  -                && method.getReturns().equals( new Type( "void", 0 ) )
  -                && method.getParameters().length == 1
  -                && method.getParameters()[ 0 ].getType().getValue().equals(
  -                    "org.apache.avalon.framework.service.ServiceManager" ) )
  +            JavaMethod[] methods = javaClass.getMethods();
  +            for( int j = 0; j < methods.length; j++ )
               {
  -                DocletTag[] dependencies = method.getTagsByName( "phoenix:dependency" );
  -                for( int i = 0; i < dependencies.length; i++ )
  +                // dependencies
  +
  +                JavaMethod method = methods[ j ];
  +                if( method.getName().equals( "service" )
  +                    && method.getReturns().equals( new Type( "void", 0 ) )
  +                    && method.getParameters().length == 1
  +                    && method.getParameters()[ 0 ].getType().getValue().equals(
  +                        "org.apache.avalon.framework.service.ServiceManager" ) )
                   {
  -                    DocletTag dependency = dependencies[ i ];
  -                    xinfo.writeDependencyLines( dependency.getNamedParameter( "name" ),
  -                            dependency.getNamedParameter( "version" ) );
  +                    DocletTag[] dependencies = method.getTagsByName( "phoenix:dependency"
);
  +                    for( int i = 0; i < dependencies.length; i++ )
  +                    {
  +                        DocletTag dependency = dependencies[ i ];
  +                        m_dependencies.put(dependency.getNamedParameter( "name" ), dependency);
  +                    }
                   }
               }
  +            javaClass = getParentClass(javaClass);
  +        }
  +
  +        Iterator it = m_dependencies.keySet().iterator();
  +        while (it.hasNext())
  +        {
  +            String dependencyName = (String) it.next();
  +            DocletTag dependency = (DocletTag) m_dependencies.get( dependencyName );
  +            xinfo.writeDependencyLines( dependencyName,
  +                            dependency.getNamedParameter( "version" ) );
           }
       }
   
  
  
  
  1.5       +4 -1      jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/tools/metagenerate/test/IntegrationTestCase.java
  
  Index: IntegrationTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/tools/metagenerate/test/IntegrationTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IntegrationTestCase.java	20 Oct 2002 10:25:51 -0000	1.4
  +++ IntegrationTestCase.java	20 Oct 2002 11:55:38 -0000	1.5
  @@ -110,7 +110,7 @@
       "      <!-- services that are offered by this block -->",
       "      <services>",
       "        <service name=\"blah.BlahService\" version=\"1.9\"/>",
  -    // "        <service name=\"blah.FooService\"/>",
  +    "        <service name=\"blah.FooService\"/>",
       "      </services>",
       "",
       "      <!-- interfaces that may be exported to manange this block -->",
  @@ -120,6 +120,9 @@
       "",
       "      <!-- services that are required by this block -->",
       "      <dependencies>",
  +    "        <dependency>",
  +    "          <service name=\"blah.OtherFooService\"/>",
  +    "        </dependency>",
       "        <dependency>",
       "          <service name=\"blah.OtherBlahService\" version=\"1.2\"/>",
       "        </dependency>",
  
  
  

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