mcconnell    2003/07/09 04:39:28

  Modified:    merlin   .cvsignore maven.xml
               merlin/merlin-platform/tutorials/context_custom/src/config
                        block.xml
               merlin/merlin-platform/tutorials/context_custom/src/java/tutorial
                        HelloComponent.xinfo
               merlin/merlin-platform/tutorials/mixed/src/config block.xml
               merlin/merlin-platform/xdocs/meta/info/type/context
                        entry.xml
               
merlin/merlin-platform/xdocs/meta/model/block/container/components/context
                        import.xml index.xml
               
merlin/merlin-platform/xdocs/meta/model/block/container/components/context/entry
                        index.xml parameter.xml
               merlin/merlin-platform/xdocs/starting/tutorial/context
                        entries.xml
               merlin/meta/src/java/org/apache/avalon/meta/data/builder
                        XMLDeploymentProfileCreator.java
               merlin/meta/src/java/org/apache/avalon/meta/data/writer
                        XMLDeploymentProfileWriter.java
               merlin/meta/src/test block.xml
               merlin/meta-spi/src/java/org/apache/avalon/meta/data
                        ContextDirective.java EntryDirective.java
                        ImportDirective.java ServiceDirective.java
  Log:
  Update to the meta-data model to reflect a cleanup of the context directive 
expression syntax/structure.  This change is not backward compatible, however, 
appropriate error messages are generated and site documetation has been updated to 
reflect changes.
  Changes result in the expression of a container context entry includes and parameter 
in a more logical form.
  
    <component ...>
       <context>
         <entry key="component-scoped-key">
            <import key="container-scoped-key"/>
         </entry>
         <entry key="my-file">
            <param class="java.io.File">../../xyz/abc.doc</param>
         </entry>
       </context>
  
  Revision  Changes    Path
  1.12      +1 -0      avalon-sandbox/merlin/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/.cvsignore,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- .cvsignore        8 Jul 2003 17:18:55 -0000       1.11
  +++ .cvsignore        9 Jul 2003 11:39:26 -0000       1.12
  @@ -6,6 +6,7 @@
   build.xml
   activation-spi
   activation
  +TODO.TXT
   
   bin
   config
  
  
  
  1.24      +1 -0      avalon-sandbox/merlin/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/maven.xml,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- maven.xml 9 Jul 2003 05:02:05 -0000       1.23
  +++ maven.xml 9 Jul 2003 11:39:26 -0000       1.24
  @@ -286,6 +286,7 @@
       <maven:reactor
         basedir="${basedir}"
         includes="*/project.xml,merlin-extensions/*/project.xml"
  +      excludes="merlin-platform/*"
         goals="clean"
         banner="Cleaning subproject:"
         ignoreFailures="false"/>
  
  
  
  1.2       +5 -3      
avalon-sandbox/merlin/merlin-platform/tutorials/context_custom/src/config/block.xml
  
  Index: block.xml
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/merlin-platform/tutorials/context_custom/src/config/block.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- block.xml 10 Jun 2003 02:12:23 -0000      1.1
  +++ block.xml 9 Jul 2003 11:39:26 -0000       1.2
  @@ -8,9 +8,11 @@
      <implementation>
        <component name="hello" class="tutorial.HelloComponent" activation="startup">
          <context>
  -         <entry key="cruncher" class="tutorial.NumberCruncher">
  -           <param class="java.lang.Integer">7</param>
  -           <param class="java.lang.Double">1.5</param>
  +         <entry key="cruncher">
  +           <param class="tutorial.NumberCruncher">
  +             <param class="java.lang.Integer">7</param>
  +             <param class="java.lang.Double">1.5</param>
  +           </param>
            </entry>
          </context>
        </component>
  
  
  
  1.2       +1 -1      
avalon-sandbox/merlin/merlin-platform/tutorials/context_custom/src/java/tutorial/HelloComponent.xinfo
  
  Index: HelloComponent.xinfo
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/merlin-platform/tutorials/context_custom/src/java/tutorial/HelloComponent.xinfo,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HelloComponent.xinfo      10 Jun 2003 02:12:23 -0000      1.1
  +++ HelloComponent.xinfo      9 Jul 2003 11:39:26 -0000       1.2
  @@ -8,6 +8,6 @@
       <version>1.0</version>
     </info>
     <context>
  -    <entry key="cruncher" type="tutorial.NumberCruncher"/>
  +    <entry key="cruncher" class="tutorial.NumberCruncher"/>
     </context>
   </type>
  
  
  
  1.2       +5 -3      
avalon-sandbox/merlin/merlin-platform/tutorials/mixed/src/config/block.xml
  
  Index: block.xml
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/merlin-platform/tutorials/mixed/src/config/block.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- block.xml 10 Jun 2003 02:12:25 -0000      1.1
  +++ block.xml 9 Jul 2003 11:39:26 -0000       1.2
  @@ -10,9 +10,11 @@
        <container name="root">
          <component name="hello" class="tutorial.HelloComponent" activation="startup">
            <context class="tutorial.DemoContextProvider">
  -           <entry key="cruncher" class="tutorial.NumberCruncher">
  -             <param class="java.lang.Integer">7</param>
  -             <param class="java.lang.Double">1.5</param>
  +           <entry key="cruncher" 
  +             <param class="tutorial.NumberCruncher">
  +               <param class="java.lang.Integer">7</param>
  +               <param class="java.lang.Double">1.5</param>
  +             </param>
              </entry>
            </context>
            <configuration>
  
  
  
  1.2       +2 -2      
avalon-sandbox/merlin/merlin-platform/xdocs/meta/info/type/context/entry.xml
  
  Index: entry.xml
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/merlin-platform/xdocs/meta/info/type/context/entry.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- entry.xml 10 Jun 2003 02:14:15 -0000      1.1
  +++ entry.xml 9 Jul 2003 11:39:26 -0000       1.2
  @@ -58,7 +58,7 @@
   
     <footer>
       <legal>
  -      Copyright (c) @year@ The Jakarta Apache Project All rights reserved.
  +      Copyright (c) @year@ The Avalon Apache Project All rights reserved.
         $Revision$ $Date$
       </legal>
     </footer>
  
  
  
  1.2       +7 -8      
avalon-sandbox/merlin/merlin-platform/xdocs/meta/model/block/container/components/context/import.xml
  
  Index: import.xml
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/merlin-platform/xdocs/meta/model/block/container/components/context/import.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- import.xml        10 Jun 2003 02:14:21 -0000      1.1
  +++ import.xml        9 Jul 2003 11:39:26 -0000       1.2
  @@ -15,15 +15,12 @@
           <table>
             <tr><th>Attribute</th><th>Required</th><th>Description</th></tr>
             <tr>
  -            <td>name</td><td>yes</td>
  -            <td>
  -                The container context key from which the context value is 
established.
  -            </td>
  -          </tr>
  -          <tr>
               <td>key</td><td>yes</td>
               <td>
  -                The context entry key referenced by the component.
  +                The container scoped context key to import into the component scope.
  +                The imported key must be know by the container.  Once established, 
  +                the value will be imported against the component key declared in 
the 
  +                enclosing entry tag.
               </td>
             </tr>
           </table>
  @@ -38,7 +35,9 @@
   <source><![CDATA[
      <profile name="basic">
        <context class="org.apache.avalon.playground.basic.BasicContextImp">
  -       <import name="urn:avalon:home" key="home" />
  +       <entry key="home">
  +         <import name="urn:avalon:home"/>
  +       </entry>
        </context>
      </profile>
   ]]></source>
  
  
  
  1.2       +6 -9      
avalon-sandbox/merlin/merlin-platform/xdocs/meta/model/block/container/components/context/index.xml
  
  Index: index.xml
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/merlin-platform/xdocs/meta/model/block/container/components/context/index.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- index.xml 10 Jun 2003 02:14:21 -0000      1.1
  +++ index.xml 9 Jul 2003 11:39:26 -0000       1.2
  @@ -31,13 +31,6 @@
           <table>
             <tr><th>Element</th><th>Cardinality</th><th>Description</th></tr>
             <tr>
  -            <td>import</td><td>n</td>
  -            <td>
  -                Declaration of the import of a container standard context entry into
  -                the context entries to supplied to the component.
  -            </td>
  -          </tr>
  -          <tr>
               <td>entry</td><td>n</td>
               <td>A context entry creation directive.</td>
             </tr>
  @@ -54,8 +47,12 @@
   <source><![CDATA[
      <profile name="basic">
        <context class="org.apache.avalon.playground.basic.BasicContextImp">
  -       <import name="urn:avalon:home" key="home" />
  -       <entry key="location">Paris</entry>
  +       <entry key="home">
  +         <import key="urn:avalon:home"/>
  +       </entry>
  +       <entry key="location">
  +         <param>Paris</param>
  +       </entry>
        </context>
      </profile>
   ]]></source>
  
  
  
  1.2       +18 -11    
avalon-sandbox/merlin/merlin-platform/xdocs/meta/model/block/container/components/context/entry/index.xml
  
  Index: index.xml
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/merlin-platform/xdocs/meta/model/block/container/components/context/entry/index.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- index.xml 10 Jun 2003 02:14:21 -0000      1.1
  +++ index.xml 9 Jul 2003 11:39:27 -0000       1.2
  @@ -22,12 +22,6 @@
                   The context entry key.
               </td>
             </tr>
  -          <tr>
  -            <td>class</td><td>no</td>
  -            <td>
  -                The context entry classname.  The default value is java.lang.String.
  -            </td>
  -          </tr>
           </table>
   
         </subsection>
  @@ -35,18 +29,25 @@
           <table>
             <tr><th>Element</th><th>Cardinality</th><th>Description</th></tr>
             <tr>
  -            <td><a href="parameter.html">parameter</a></td><td>n</td>
  +            <td><a href="parameter.html">param</a></td><td>1 (or import)</td>
               <td>
               A constructor argument.If the value of the element is not empty, the 
value will be 
               used as a default constructor argument.  Otherwise, Merlin will attempt 
to 
               locate nested parameter elements in order to build a new instance.
               </td>
             </tr>
  +          <tr>
  +            <td>import</td><td>1 (or param)</td>
  +            <td>
  +                Declaration of the import of a container standard context entry into
  +                the context entries to supplied to the component.
  +            </td>
  +          </tr>
           </table>
         </subsection>
   
         <subsection name="Description">
  -<p>A context entry directive defines the creation of a tagged object.  The context 
entry includes and key and either an implict java.lang.String value and or a set of 
constructor arguments.</p>
  +<p>A context entry directive defines the creation of a tagged object.</p>
         </subsection>
   
         <subsection name="Sample XML">
  @@ -54,9 +55,15 @@
   <source><![CDATA[
      <profile name="basic">
        <context class="org.apache.avalon.playground.basic.BasicContextImp">
  -       <import name="urn:avalon:home" key="home"/>
  -       <entry key="location">Paris</entry>
  -       <entry key="working" class="java.io.File">cache</entry>
  +       <entry key="home">
  +         <import key="urn:avalon:home"/>
  +       </entry>
  +       <entry key="location">
  +         <param>Paris</param>
  +       </entry>
  +       <entry key="working">
  +         <param class="java.io.File">../../lib/cache</param>
  +       </entry>
        </context>
      </profile>
   ]]></source>
  
  
  
  1.2       +8 -6      
avalon-sandbox/merlin/merlin-platform/xdocs/meta/model/block/container/components/context/entry/parameter.xml
  
  Index: parameter.xml
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/merlin-platform/xdocs/meta/model/block/container/components/context/entry/parameter.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- parameter.xml     10 Jun 2003 02:14:22 -0000      1.1
  +++ parameter.xml     9 Jul 2003 11:39:27 -0000       1.2
  @@ -49,12 +49,14 @@
   <source><![CDATA[
      <profile name="basic">
        <context class="org.apache.avalon.playground.basic.BasicContextImp">
  -       <entry key="gws" class="ReallySpecialClass">
  -         <param class="java.io.File">temp</param>
  -         <param>George C. Scott</param>
  -         <param class="SpecialClass">
  -           <param>100</param>
  -           <param>200</param>
  +       <entry key="gws">
  +         <param class="ReallySpecialClass">
  +           <param class="java.io.File">temp</param>
  +           <param>George C. Scott</param>
  +           <param class="SpecialClass">
  +             <param>100</param>
  +             <param>200</param>
  +           </param>
            </param>
          </entry>
        </context>
  
  
  
  1.2       +6 -4      
avalon-sandbox/merlin/merlin-platform/xdocs/starting/tutorial/context/entries.xml
  
  Index: entries.xml
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/merlin-platform/xdocs/starting/tutorial/context/entries.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- entries.xml       10 Jun 2003 02:14:36 -0000      1.1
  +++ entries.xml       9 Jul 2003 11:39:27 -0000       1.2
  @@ -32,7 +32,7 @@
             with an existing code base.
           </p>
           <p>
  -          Out non-componet example NumberCruncher takes two values
  +          Our non-componet example NumberCruncher takes two values
             in a constructor and returns the result of the multiplication
             of the two number via an accessor.  While not very useful, the  
             purpose of NumberCruncher is to demonstrate how you can use 
  @@ -150,9 +150,11 @@
      <implementation>
        <component name="hello" class="tutorial.HelloComponent" activation="startup">
          <context>
  -         <entry key="cruncher" class="tutorial.NumberCruncher">
  -           <param class="java.lang.Integer">7</param>
  -           <param class="java.lang.Double">1.5</param>
  +         <entry key="cruncher">
  +           <param class="tutorial.NumberCruncher">
  +             <param class="java.lang.Integer">7</param>
  +             <param class="java.lang.Double">1.5</param>
  +           </param>
            </entry>
          </context>
        </component>
  
  
  
  1.3       +39 -35    
avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/builder/XMLDeploymentProfileCreator.java
  
  Index: XMLDeploymentProfileCreator.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/builder/XMLDeploymentProfileCreator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLDeploymentProfileCreator.java  7 Jul 2003 08:31:20 -0000       1.2
  +++ XMLDeploymentProfileCreator.java  9 Jul 2003 11:39:28 -0000       1.3
  @@ -123,25 +123,25 @@
           {
               String priority = config.getAttribute( "priority", null );
               String target = target = config.getAttribute( "target", null );
  -            CategoryDirective[] categories = getCategoryDirectiveDirectives( 
config.getChildren( "category" ) );
  +            CategoryDirective[] categories = getCategoryDirectives( 
config.getChildren( "category" ) );
               return new CategoriesDirective( name, priority, target, categories );
           }
           return null;
       }
   
  -    private CategoryDirective[] getCategoryDirectiveDirectives( Configuration[] 
children )
  +    private CategoryDirective[] getCategoryDirectives( Configuration[] children )
         throws ConfigurationException
       {
           ArrayList list = new ArrayList();
           for( int i = 0; i < children.length; i++ )
           {
  -            CategoryDirective category = getCategoryDirectiveDirective( children[ i 
] );
  +            CategoryDirective category = getCategoryDirective( children[ i ] );
               list.add( category );
           }
           return (CategoryDirective[]) list.toArray( new CategoryDirective[0] );
       }
   
  -    private CategoryDirective getCategoryDirectiveDirective( Configuration config )
  +    private CategoryDirective getCategoryDirective( Configuration config )
         throws ConfigurationException
       {
           final String name = config.getAttribute( "name" );
  @@ -170,32 +170,23 @@
       public ContextDirective getContextDirective( Configuration config )
           throws ConfigurationException
       {
  -        if( config != null )
  +        if( config == null )
           {
  -            String classname = config.getAttribute( "class", null );
  -            ImportDirective[] imports = getImportDirectives( config.getChildren( 
"import" ) );
  -            EntryDirective[] entries = getEntries( config.getChildren( "entry" ) );
  -            return new ContextDirective( classname, imports, entries );
  +            return null;
           }
  -        return null;
  -    }
   
  -    /**
  -     * Utility method to create a set of import directive.
  -     *
  -     * @param configs the import directive configurations
  -     * @return the import directives
  -     * @throws ConfigurationException if an error occurs
  -     */
  -    protected ImportDirective[] getImportDirectives( Configuration[] configs )
  -        throws ConfigurationException
  -    {
  -        ArrayList list = new ArrayList();
  -        for( int i = 0; i < configs.length; i++ )
  +        if( config.getChildren( "import" ).length > 0 )
           {
  -            list.add( getImportDirective( configs[ i ] ) );
  +            final String error = 
  +              "The 'context' tag format has changed."
  +              + " Please check Merlin home for details "
  +              + "http://avalon.apache.org/sandbox/merlin/resources";;
  +            throw new ConfigurationException( error );
           }
  -        return (ImportDirective[])list.toArray( new ImportDirective[ 0 ] );
  +
  +        final String classname = config.getAttribute( "class", null );
  +        EntryDirective[] entries = getEntries( config.getChildren( "entry" ) );
  +        return new ContextDirective( classname, entries );
       }
   
       /**
  @@ -208,9 +199,17 @@
       protected ImportDirective getImportDirective( Configuration config )
           throws ConfigurationException
       {
  +        if( config.getAttribute( "name", null ) != null )
  +        {
  +            final String error = 
  +              "The 'import' tag format has changed."
  +              + " Please check Merlin Home for details "
  +              + "http://avalon.apache.org/sandbox/merlin/resources";;
  +            throw new ConfigurationException( error );
  +        }
  +
           final String key = config.getAttribute( "key" );
  -        final String path = config.getAttribute( "name", null );
  -        return new ImportDirective( key, path );
  +        return new ImportDirective( key );
       }
   
       /**
  @@ -243,17 +242,22 @@
           throws ConfigurationException
       {
           String key = config.getAttribute( "key" );
  -        String classname = config.getAttribute( "class", "java.lang.String" );
  -        String value = config.getValue( null );
  -        if( value != null )
  +        if( config.getChild( "import", false ) != null )
  +        {
  +            ImportDirective imp = getImportDirective( config.getChild( "import" ) );
  +            return new EntryDirective( key, imp );
  +        }
  +        else if( config.getChild( "param", false ) != null )
           {
  -            return new EntryDirective( key, classname, value );
  +            Parameter param = getParameter( config.getChild( "param" ) );
  +            return new EntryDirective( key, param );
           }
           else
           {
  -            Configuration[] params = config.getChildren( "param" );
  -            Parameter[] parameters = getParameters( params );
  -            return new EntryDirective( key, classname, parameters );
  +            final String error = 
  +              "Entry directive format has changed."
  +              + " New structure requires a single embedded 'import' or a 'param' 
element.";
  +            throw new ConfigurationException( error );
           }
       }
   
  
  
  
  1.3       +37 -39    
avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/writer/XMLDeploymentProfileWriter.java
  
  Index: XMLDeploymentProfileWriter.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/data/writer/XMLDeploymentProfileWriter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLDeploymentProfileWriter.java   6 Jul 2003 10:08:18 -0000       1.2
  +++ XMLDeploymentProfileWriter.java   9 Jul 2003 11:39:28 -0000       1.3
  @@ -100,15 +100,15 @@
           if(( profile.getCategories() == null ) && ( profile.getContext() == null )
            && ( profile.getConfiguration() == null ) && (profile.getParameters() == 
null ))
           {
  +            writer.write( "/>");
  +        }
  +        else
  +        {
               writer.write( ">" );
               final String padding = pad + INDENT;
               writeDeploymentBody( writer, profile, padding );
               writer.write( "\n" + pad + "</component>" );
           }
  -        else
  -        {
  -            writer.write( "/>");
  -        }
       }
   
      /**
  @@ -238,10 +238,9 @@
               writer.write( " class=\"" + context.getClassname() + "\"");
           }
   
  -        ImportDirective[] imports = context.getImportDirectives();
           EntryDirective[] entries = context.getEntries();
   
  -        if( ( imports.length == 0 ) && ( entries.length == 0 ))
  +        if( entries.length == 0 )
           {
               writer.write( "/>" );
               return;
  @@ -252,50 +251,48 @@
               final String padding = pad + INDENT;
   
               //
  -            // write out the context imports
  -            //
  -
  -            for( int i=0; i<imports.length; i++ )
  -            {
  -                ImportDirective imp = imports[i];
  -                writer.write( "\n" + padding + "<import" );
  -                writer.write( " name=\"" + imp.getImportDirectiveName() + "\"" );
  -                writer.write( " key=\"" + imp.getKey() + "\"" );
  -                writer.write( "/>" );
  -            }
  -
  -            //
  -            // write out any entry constructor directives
  +            // write out the entry directives
               //
   
               final String fill = padding + INDENT;
               for( int i=0; i<entries.length; i++ )
               {
                   EntryDirective entry = entries[i];
  -                writer.write( "\n" + padding + "<entry" );
  -                writer.write( " key=\"" + entry.getKey() + "\"" );
  -                if( entry.getClassname() != null )
  -                {
  -                    writer.write( " class=\"" + entry.getClassname() + "\"" );
  -                }
  -                Parameter[] params = entry.getParameters();
  -                if( params.length == 0 )
  -                {
  -                    writer.write( ">" + entry.getArgument() );
  -                }
  -                else
  -                {
  -                    writer.write( ">");
  -                    writeParams( writer, params, fill );
  -                }
  -                writer.write( "\n" + pad + INDENT + "</entry>" );
  +                writeEntryDirective( writer, entry, fill );
               }
  -
               writer.write( "\n" + pad + "</context>" );
           }
       }
   
       /**
  +     * Write out xml representation of a entry directive
  +     *
  +     * @param writer the writer
  +     * @param entry the entry directive
  +     * @throws IOException if unable to write xml
  +     */
  +    private void writeEntryDirective( 
  +      final Writer writer, final EntryDirective entry, String pad )
  +      throws IOException
  +    {
  +        final String padding = pad + INDENT;
  +        writer.write( "\n" + pad + "<entry" );
  +        writer.write( " key=\"" + entry.getKey() + "\">" );
  +        if( entry.getMode() == EntryDirective.IMPORT )
  +        {
  +            ImportDirective imp = entry.getImportDirective();
  +            writer.write( "\n" + padding + "<import" );
  +            writer.write( " key=\"" + imp.getKey() + "\"" );
  +            writer.write( "/>" );
  +        }
  +        else if( entry.getMode() == EntryDirective.PARAM )
  +        {
  +            writeParam( writer, entry.getParameter(), padding );
  +        }
  +        writer.write( "\n" + pad + "</entry>" );
  +    }
  +
  +    /**
        * Write out xml representation of a set of parameters.
        *
        * @param writer the writer
  @@ -334,6 +331,7 @@
           {
               final String padding = pad + INDENT;
               writeParams( writer, parameters, padding );
  +            writer.write( "\n" + pad + "</param>" );
           }
           else
           {
  
  
  
  1.3       +11 -4     avalon-sandbox/merlin/meta/src/test/block.xml
  
  Index: block.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta/src/test/block.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- block.xml 6 Jul 2003 10:08:18 -0000       1.2
  +++ block.xml 9 Jul 2003 11:39:28 -0000       1.3
  @@ -38,10 +38,17 @@
            <category name="aaaaa"/>
          </categories>
          <context class="MyContextImpl">
  -         <import name="urn:avalon:home" key="home"/>
  -         <entry key="abc" class="java.io.File">here/there.xml</entry>
  -         <entry key="batman" class="MyEntry">
  -           <param>abc</param>
  +         <entry key="abc">
  +           <param class="java.io.File">here/there.xml</param>
  +         </entry>
  +         <entry key="batman">
  +           <param class="MyEntryClass">
  +             <param>abc</param>
  +             <param>def</param>
  +           </param>
  +         </entry>
  +         <entry key="green-lantern">
  +           <import key="urn:avalon:classloader"/>
            </entry>
          </context>
          <configuration>
  
  
  
  1.3       +13 -47    
avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ContextDirective.java
  
  Index: ContextDirective.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ContextDirective.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ContextDirective.java     8 Jul 2003 14:06:42 -0000       1.2
  +++ ContextDirective.java     9 Jul 2003 11:39:28 -0000       1.3
  @@ -62,19 +62,19 @@
    * statement corresponds to a request for a context value from the container.</p>
    * <pre>
    *    &lt;context class="<font color="darkred">MyContextCLass</font>"&gt;
  - *       &lt;import name="<font color="darkred">classloader</font>" key="<font 
color="darkred">special.classloader</font>"/&gt;
  - *       &lt;import name="<font color="darkred">urn:avalon:home</font>" key="<font 
color="darkred">base</font>"/&gt;
  - *       &lt;entry key="<font color="darkred">location</font>" value="<font 
color="darkred">Paris</font>"/&gt;
  - *       &lt;entry key="<font color="darkred">special</font>" class="<font 
color="darkred">MySpecialClass</font>"&gt;
  - *         &lt;parameter&gt<font color="darkred">hello</font>&lt;/parameter&gt;
  - *         &lt;parameter class="<font 
color="darkred">java.lang.ClassLoader</font>"&gt<font 
color="darkred">%{special.classloader}</font>&lt;/parameter&gt;
  - *       &lt;/entry&gt
  + *       &lt;entry key="<font color="darkred">special</font>"&gt;
  + *         &lt;import key="<font color="darkred">urn:avalon:classloader</font>"/&gt;
  + *       &lt;/entry&gt;
  + *       &lt;entry key="<font color="darkred">xxx</font>"&gt;
  + *         &lt;param class="<font color="darkred">MySpecialClass</font>"&gt;
  + *           &lt;param&gt<font color="darkred">hello</font>&lt;/param&gt;
  + *           &lt;param class="<font color="darkred">java.io.File</font>"&gt;<font 
color="darkred">../lib</font>&lt;/param&gt;
  + *         &lt;/param&gt;
  + *       &lt;/entry&gt;
    *    &lt;/context&gt;
    * </pre>
    *
    * @see EntryDirective
  - * @see ImportDirective
  - * @see Parameter
    * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  @@ -86,12 +86,7 @@
       private final EntryDirective[] m_entries;
   
       /**
  -     * The set of import directives.
  -     */
  -    private final ImportDirective[] m_imports;
  -
  -    /**
  -     * The context implementation classname.
  +     * The set of entry directives.
        */
       private final String m_classname;
   
  @@ -101,11 +96,10 @@
        * @param imports the set of import directives
        * @param entries the set of entry descriptors
        */
  -    public ContextDirective( final String classname, final ImportDirective[] 
imports, final EntryDirective[] entries )
  +    public ContextDirective( final String classname, final EntryDirective[] entries 
)
       {
  -        m_classname = classname;
  -        m_imports = imports;
           m_entries = entries;
  +        m_classname = classname;
       }
   
       /**
  @@ -140,34 +134,6 @@
               if( entry.getKey().equals( key ) )
               {
                   return entry;
  -            }
  -        }
  -        return null;
  -    }
  -
  -    /**
  -     * Return the set of import directives.
  -     * @return the imports
  -     */
  -    public ImportDirective[] getImportDirectives()
  -    {
  -        return m_imports;
  -    }
  -
  -    /**
  -     * Return a named import directive.
  -     * @param key the import key
  -     * @return the import directive corresponding to the supplied key or null if the
  -     *   key is unknown
  -     */
  -    public ImportDirective getImportDirective( String key )
  -    {
  -        for( int i = 0; i < m_imports.length; i++ )
  -        {
  -            ImportDirective imp = m_imports[ i ];
  -            if( imp.getKey().equals( key ) )
  -            {
  -                return imp;
               }
           }
           return null;
  
  
  
  1.2       +70 -18    
avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/EntryDirective.java
  
  Index: EntryDirective.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/EntryDirective.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EntryDirective.java       3 Jul 2003 04:28:55 -0000       1.1
  +++ EntryDirective.java       9 Jul 2003 11:39:28 -0000       1.2
  @@ -50,66 +50,91 @@
   
   package org.apache.avalon.meta.data;
   
  +import java.io.Serializable;
  +
   /**
  - * A entry descriptor declares the context entry creation criteria for
  + * A entry descriptor declares the context entry import or creation criteria for
    * a single context entry instance.
    *
    * <p><b>XML</b></p>
  - * <p>A entry may container either (a) body content, or (b) a set of constructor
  - * parameters to be applied as arguments to a constructor of the supplied 
classname.</p>
  + * <p>A entry may contain either (a) a single nested import directive, or (b) a 
single param constructor directives.</p>
    * <pre>
    *  <font color="gray">&lt;context&gt;</font>
  - *    &lt;entry key="<font color="darkred">location</font>"&gt;<font 
color="darkred">Paris</font>&lt/entry&gt;;
  - *    &lt;entry key="<font color="darkred">home</font>" class="<font 
color="darkred">java.io.File</font>"&gt;<font 
color="darkred">../home</font>&lt/entry&gt;;
  - *    &lt;entry key="<font color="darkred">special</font>" class="<font 
color="darkred">MyObjectCLass</font>"&gt;
  - *      &lt;parameter"&gt;<font color="darkred">Paris</font>&lt/parameter&gt;
  - *      &lt;parameter class="<font color="darkred">java.io.File</font>"&gt;<font 
color="darkred">../home</font>&lt/parameter&gt;
  + *
  + *    &lt!-- option (a) nested import -->
  + *    &lt;entry key="<font color="darkred">my-home-dir</font>"&gt;
  + *       &lt;include key="<font color="darkred">urn:avalon:home</font>"/&gt;
  + *    &lt;/entry&gt;
  + *
  + *    &lt!-- option (b) param constructors -->
  + *    &lt;entry key="<font color="darkred">title</font>"&gt;
  + *       &lt;param&gt;<font color="darkred">Lord of the Rings</font>&lt;/&gt;
    *    &lt;/entry&gt;
  + *    &lt;entry key="<font color="darkred">home</font>"&gt;
  + *      &lt;param class="<font color="darkred">java.io.File</font>"&gt;<font 
color="darkred">../home</font>&lt;/param&gt;
  + *    &lt;/entry&gt;
  + *
    *  <font color="gray">&lt;/context&gt;</font>
    * </pre>
    *
  + * @see ImportDirective
    * @see Parameter
    * @see ContextDirective
    * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  -public class EntryDirective extends Parameter
  +public class EntryDirective implements Serializable
   {
  +     public static final int IMPORT = 0;
  +
  +     public static final int PARAM = 1;
  +
  +     public static final int PROVIDER = 2;
  +
       /**
        * The entry key.
        */
       private final String m_key;
   
  +    private final ImportDirective m_target;
  +
  +    private final Parameter m_param;
  +
  +    private final int m_mode;
  +
       /**
  -     * Creation of a new entry directive.
  +     * Creation of a new entry directive using a import directive.
        * @param key the entry key
  -     * @param classname the classname of the entry implementation
  -     * @param value a single constructor argument value
  +     * @param target the import directive defining the target key name
        */
  -    public EntryDirective( final String key, final String classname, final String 
value )
  +    public EntryDirective( final String key, final ImportDirective target )
       {
  -        super( classname, value );
           if( null == key )
           {
               throw new NullPointerException( "key" );
           }
           m_key = key;
  +        m_target = target;
  +        m_mode = IMPORT;
  +        m_param = null;
       }
   
       /**
  -     * Creation of a new entry directive.
  +     * Creation of a new entry directive using a parameter.
        * @param key the entry key
        * @param classname the classname of the entry implementation
        * @param parameters implementation class constructor parameter directives
        */
  -    public EntryDirective( final String key, final String classname, final 
Parameter[] parameters )
  +    public EntryDirective( final String key, final Parameter parameter )
       {
  -        super( classname, parameters );
           if( null == key )
           {
               throw new NullPointerException( "key" );
           }
           m_key = key;
  +        m_param = parameter;
  +        m_mode = PARAM;
  +        m_target = null;
       }
   
       /**
  @@ -119,5 +144,32 @@
       public String getKey()
       {
           return m_key;
  +    }
  +
  +    /**
  +     * Return the entry mode (IMPORT, PARAM or PROVIDER)
  +     * @return the mode
  +     */
  +    public int getMode()
  +    {
  +        return m_mode;
  +    }
  +
  +    /**
  +     * Return the import directive if the mode is IMPORT else null.
  +     * @return the directive
  +     */
  +    public ImportDirective getImportDirective()
  +    {
  +        return m_target;
  +    }
  +
  +    /**
  +     * Return the parameter directive if the mode is PARAM else null.
  +     * @return the directive
  +     */
  +    public Parameter getParameter()
  +    {
  +        return m_param;
       }
   }
  
  
  
  1.2       +7 -32     
avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ImportDirective.java
  
  Index: ImportDirective.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ImportDirective.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ImportDirective.java      3 Jul 2003 04:28:55 -0000       1.1
  +++ ImportDirective.java      9 Jul 2003 11:39:28 -0000       1.2
  @@ -64,17 +64,16 @@
    *    <font color="gray">
    *    &lt;--
    *    Declare the import of the value of "urn:avalon:home" as a keyed context
  - *    value using the key "home".
  + *    entry using the key "home".
    *    --&gt;</font>
    *
    *  <font color="gray">&lt;context&gt;</font>
  - *    &lt;import key="<font color="darkred">home</font>" name="<font 
color="darkred">urn:avalon:home</font>"&gt;;
  + *    <font color="gray">&lt;entry key="home">&gt;</font>
  + *      &lt;import key="<font color="darkred">urn:avalon:home</font>"/&gt;
  + *    <font color="gray">&lt;/entry&gt;</font>
    *  <font color="gray">&lt;/context&gt;</font>
    * </pre>
    *
  - * ImportDirectiveed context entries may be referenced by parameter values using the
  - * "<code>${&lt;key&gt;}</code>" notation.
  - *
    * @see ContextDirective
    * @see EntryDirective
    * @see Parameter
  @@ -89,40 +88,16 @@
       private final String m_key;
   
       /**
  -     * The container's context entry key.
  -     */
  -    private final String m_name;
  -
  -    /**
        * Creation of a new entry directive.
  -     * @param key the local key that will be used by clients to access the object 
via a context
  -     * @param name the container scoped context entry name
  +     * @param key the container scope key value to import
        */
  -    public ImportDirective( final String key, final String name )
  +    public ImportDirective( final String key )
       {
           if( null == key )
           {
               throw new NullPointerException( "key" );
           }
  -
           m_key = key;
  -        if( null == name )
  -        {
  -            m_name = key;
  -        }
  -        else
  -        {
  -            m_name = name;
  -        }
  -    }
  -
  -    /**
  -     * Returns the key of the context entry to import.
  -     * @return the import key value
  -     */
  -    public String getImportDirectiveName()
  -    {
  -        return m_name;
       }
   
       /**
  
  
  
  1.2       +5 -2      
avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ServiceDirective.java
  
  Index: ServiceDirective.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/data/ServiceDirective.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServiceDirective.java     3 Jul 2003 04:28:55 -0000       1.1
  +++ ServiceDirective.java     9 Jul 2003 11:39:28 -0000       1.2
  @@ -52,7 +52,7 @@
   import org.apache.avalon.meta.info.ServiceDescriptor;
   
   /**
  - * A VirtualService is a class that holds a reference to a published
  + * A ServiceDirective is a class that holds a reference to a published
    * service together with a component implmentation path reference, referencing 
    * the component implementing the service.
    *
  @@ -76,6 +76,9 @@
       public ServiceDirective( ServiceDescriptor descriptor, String path )
       {
           super( descriptor );
  +
  +        // TODO: put in place relative and absolute addressing
  +
           if( path.startsWith( "/" ) )
           {
               m_path = path.substring( 1, path.length() );
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to