hammant     2002/10/20 02:19:29

  Modified:    src/java/org/apache/avalon/phoenix/tools/metagenerate
                        XinfoFactory.java XinfoHelper.java
               src/test/org/apache/avalon/phoenix/tools/metagenerate/test
                        IntegrationTestCase.java TestBlock.java
  Log:
  version="x" for services and deps back.
  
  Revision  Changes    Path
  1.4       +39 -4     
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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XinfoFactory.java 18 Oct 2002 08:44:07 -0000      1.3
  +++ XinfoFactory.java 20 Oct 2002 09:19:29 -0000      1.4
  @@ -41,11 +41,11 @@
       public void generate() throws IOException
       {
           File file = new File( m_destDir,
  -                              m_javaClass.getFullyQualifiedName().replace( '.', 
File.separatorChar ) + ".xinfo" );
  +             m_javaClass.getFullyQualifiedName().replace( '.', File.separatorChar ) 
+ ".xinfo" );
           file.getParentFile().mkdirs();
           XinfoHelper xinfo = new XinfoHelper( file );
   
  -        xinfo.writeHeader();
  +        xinfo.writeHeader(getConfigurationSchema());
   
           // services
   
  @@ -74,7 +74,8 @@
           for( int i = 0; i < services.length; i++ )
           {
               DocletTag service = services[ i ];
  -            xinfo.writeServiceLines( service.getNamedParameter( "name" ) );
  +            xinfo.writeServiceLines( service.getNamedParameter( "name" ),
  +                    service.getNamedParameter("version") );
           }
       }
   
  @@ -115,9 +116,43 @@
                   for( int i = 0; i < dependencies.length; i++ )
                   {
                       DocletTag dependency = dependencies[ i ];
  -                    xinfo.writeDependencyLines( dependency.getNamedParameter( 
"name" ) );
  +                    xinfo.writeDependencyLines( dependency.getNamedParameter( 
"name" ),
  +                            dependency.getNamedParameter( "version" ) );
                   }
               }
           }
  +    }
  +
  +    /**
  +     * Get the configuaation schema type
  +     * @return The type.
  +     */
  +    protected String getConfigurationSchema()
  +    {
  +        JavaMethod[] methods = m_javaClass.getMethods();
  +        for (int j = 0; j < methods.length; j++)
  +        {
  +            // dependencies
  +
  +            JavaMethod method = methods[j];
  +            if (method.getName().equals("configure")
  +                    && method.getReturns().equals(new Type("void",0))
  +                    && method.getParameters().length == 1
  +                    && method.getParameters()[0].getType().getValue().equals(
  +                            
"org.apache.avalon.framework.configuration.Configuration"))
  +            {
  +                DocletTag[] dependencies = 
method.getTagsByName("phoenix:configuration-schema");
  +                for (int i = 0; i < dependencies.length; i++)
  +                {
  +                    DocletTag dependency = dependencies[i];
  +                    String typeQt = dependency.getNamedParameter("type");
  +                    if (typeQt.length() > 2)
  +                    {
  +                        return typeQt.substring(1,typeQt.length()-1);
  +                    }
  +                }
  +            }
  +        }
  +        return null;
       }
   }
  
  
  
  1.3       +76 -52    
jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/metagenerate/XinfoHelper.java
  
  Index: XinfoHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/metagenerate/XinfoHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XinfoHelper.java  2 Oct 2002 11:11:58 -0000       1.2
  +++ XinfoHelper.java  20 Oct 2002 09:19:29 -0000      1.3
  @@ -13,55 +13,61 @@
   
   /**
    * A Xinfo Helper.
  -  * @author Paul Hammant
  + * @author Paul Hammant
    */
   public class XinfoHelper extends AbstractHelper
   {
   
       private FileWriter m_output;
   
  -    private static final String[] HEADER = new String[] {
  -    "<?xml version=\"1.0\"?>",
  -    "<!DOCTYPE blockinfo PUBLIC \"-//PHOENIX/Block Info DTD Version 1.0//EN\"",
  -    "                  
\"http://jakarta.apache.org/avalon/dtds/phoenix/blockinfo_1_0.dtd\";>",
  -    "",
  -    "<blockinfo>",
  -    "",
  -    "  <!-- section to describe block -->",
  -    "  <block>",
  -    "    <version>1.0</version>",
  -    "  </block>",
  -    "",
  -    "  <!-- services that are offered by this block -->",
  -    "  <services>" };
  -
  -    private static final String[] SERVICE_LINES = new String[] {
  -    "    <service name=\"@SERVICE-CLASS@\"/>" };
  -
  -    private static final String[] END_OF_SERVICES = new String[] {
  -    "  </services>",
  -    "",
  -    "  <!-- interfaces that may be exported to manange this block -->",
  -    "  <management-access-points>" };
  -
  -    private static final String[] MANAGEMENT_LINE = new String[] {
  -    "     <service name=@INTERFACE-NAME@/>" };
  -
  -    private static final String[] END_OF_MGMT = new String[] {
  -    "  </management-access-points>",
  -    "",
  -    "  <!-- services that are required by this block -->",
  -    "  <dependencies>" };
  -
  -    private static final String[] DEPENDENCY_SECTION = new String[] {
  -
  -    "    <dependency>",
  -    "      <service name=\"@SERVICE-CLASS@\"/>",
  -    "    </dependency>" };
  -
  -    private static final String[] FOOTER = new String[] {
  -    "  </dependencies>",
  -    "</blockinfo>" };
  +    private static final String[] HEADER1 = new String[] {
  +        "<?xml version=\"1.0\"?>",
  +        "<!DOCTYPE blockinfo PUBLIC \"-//PHOENIX/Block Info DTD Version 1.0//EN\"",
  +        "                  
\"http://jakarta.apache.org/avalon/dtds/phoenix/blockinfo_1_0.dtd\";>",
  +        "",
  +        "<blockinfo>",
  +        "",
  +        "  <!-- section to describe block -->",
  +        "  <block>",
  +        "    <version>1.0</version>"};
  +
  +    private static final String[] HEADER2 = new String[]{
  +        "    <schema-type>@CONFIG-TYPE@</schema-type>"};
  +
  +    private static final String[] HEADER3 = new String[]{
  +        "  </block>",
  +        "",
  +        "  <!-- services that are offered by this block -->",
  +        "  <services>"};
  +
  +    private static final String[] SERVICE_LINES = new String[]{
  +        "    <service name=\"@SERVICE-CLASS@\"@VERSION@/>"};
  +
  +    private static final String[] END_OF_SERVICES = new String[]{
  +        "  </services>",
  +        "",
  +        "  <!-- interfaces that may be exported to manange this block -->",
  +        "  <management-access-points>"};
  +
  +    private static final String[] MANAGEMENT_LINE = new String[]{
  +        "     <service name=@INTERFACE-NAME@/>"};
  +
  +    private static final String[] END_OF_MGMT = new String[]{
  +        "  </management-access-points>",
  +        "",
  +        "  <!-- services that are required by this block -->",
  +        "  <dependencies>"};
  +
  +    private static final String[] DEPENDENCY_SECTION = new String[]{
  +
  +        "    <dependency>",
  +        "      <service name=\"@SERVICE-CLASS@\"@VERSION@/>",
  +        "    </dependency>"};
  +
  +    private static final String[] FOOTER = new String[]{
  +        "  </dependencies>",
  +        "</blockinfo>"};
  +
   
       /**
        * Construct
  @@ -77,11 +83,25 @@
        * Write the header
        * @throws IOException If a problem writing output
        */
  -    public void writeHeader() throws IOException
  +    public void writeHeader(String configType) throws IOException
       {
  -        for (int i = 0; i < HEADER.length; i++)
  +        for (int i = 0; i < HEADER1.length; i++)
  +        {
  +            m_output.write(HEADER1[i] + "\n");
  +        }
  +        if (configType != null)
           {
  -            m_output.write(HEADER[i] + "\n");
  +            for (int i = 0; i < HEADER2.length; i++)
  +            {
  +                String line = HEADER2[i];
  +                line = replaceString(line, "@CONFIG-TYPE@", configType);
  +                m_output.write(line + "\n");
  +
  +            }
  +        }
  +        for (int i = 0; i < HEADER3.length; i++)
  +        {
  +            m_output.write(HEADER3[i] + "\n");
           }
       }
   
  @@ -90,13 +110,15 @@
        * @param service The service name
        * @throws IOException If a problem writing output
        */
  -    public void writeServiceLines(String service) throws IOException
  +    public void writeServiceLines(String service, String version) throws IOException
       {
  +        version = version == null ? "" : " version=" + version;
           for (int i = 0; i < SERVICE_LINES.length; i++)
           {
  -            String line =  SERVICE_LINES[i];
  +            String line = SERVICE_LINES[i];
               line = replaceString(line, "\"@SERVICE-CLASS@\"", service);
  -            m_output.write(line  + "\n");
  +            line = replaceString(line, "@VERSION@", version);
  +            m_output.write(line + "\n");
           }
       }
   
  @@ -116,7 +138,7 @@
       {
           for (int i = 0; i < MANAGEMENT_LINE.length; i++)
           {
  -            String line =  MANAGEMENT_LINE[i];
  +            String line = MANAGEMENT_LINE[i];
               line = replaceString(line, "@INTERFACE-NAME@", interfaceName);
               m_output.write(line + "\n");
           }
  @@ -141,12 +163,14 @@
        * @param dependency The Dependency
        * @throws IOException If a problem writing output
        */
  -    public void writeDependencyLines(String dependency) throws IOException
  +    public void writeDependencyLines(String dependency, String version) throws 
IOException
       {
  +        version = version == null ? "" : " version=" + version;
           for (int i = 0; i < DEPENDENCY_SECTION.length; i++)
           {
  -            String line =  DEPENDENCY_SECTION[i];
  +            String line = DEPENDENCY_SECTION[i];
               line = replaceString(line, "\"@SERVICE-CLASS@\"", dependency);
  +            line = replaceString(line, "@VERSION@", version);
               m_output.write(line + "\n");
           }
       }
  
  
  
  1.3       +3 -2      
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IntegrationTestCase.java  2 Oct 2002 11:25:56 -0000       1.2
  +++ IntegrationTestCase.java  20 Oct 2002 09:19:29 -0000      1.3
  @@ -104,11 +104,12 @@
       "      <!-- section to describe block -->",
       "      <block>",
       "        <version>1.0</version>",
  +    "        <schema-type>abc</schema-type>",
       "      </block>",
       "",
       "      <!-- services that are offered by this block -->",
       "      <services>",
  -    "        <service name=\"blah.BlahService\"/>",
  +    "        <service name=\"blah.BlahService\" version=\"1.9\"/>",
       "      </services>",
       "",
       "      <!-- interfaces that may be exported to manange this block -->",
  @@ -119,7 +120,7 @@
       "      <!-- services that are required by this block -->",
       "      <dependencies>",
       "        <dependency>",
  -    "          <service name=\"blah.OtherBlahService\"/>",
  +    "          <service name=\"blah.OtherBlahService\" version=\"1.2\"/>",
       "        </dependency>",
       "      </dependencies>",
       "    </blockinfo>" };
  
  
  
  1.2       +12 -3     
jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/tools/metagenerate/test/TestBlock.java
  
  Index: TestBlock.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-phoenix/src/test/org/apache/avalon/phoenix/tools/metagenerate/test/TestBlock.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestBlock.java    1 Oct 2002 06:43:14 -0000       1.1
  +++ TestBlock.java    20 Oct 2002 09:19:29 -0000      1.2
  @@ -10,24 +10,33 @@
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
   
   /**
    * Blah!
    *
    * @phoenix:block
  - * @phoenix:service name="blah.BlahService"
  + * @phoenix:service name="blah.BlahService" version="1.9"
    * @phoenix:mx name="YeeeHaaa"
    *
    */
  -public class TestBlock implements Serviceable
  +public class TestBlock implements Serviceable, Configurable
   {
       /**
  -     * @phoenix:dependency name="blah.OtherBlahService"
  +     * @phoenix:dependency name="blah.OtherBlahService" version="1.2"
        */
       public void service( final ServiceManager serviceManager )
           throws ServiceException
       {
   
  +    }
  +
  +    /**
  +     * @phoenix:configuration-schema type="abc"
  +     */
  +    public void configure(Configuration configuration) throws 
ConfigurationException {
       }
   
   
  
  
  

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

Reply via email to