avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder XMLProfileCreator.java
Date Fri, 19 Jul 2002 14:08:07 GMT
mcconnell    2002/07/19 07:08:07

  Modified:    assembly/demo/src/java/org/apache/excalibur/playground
                        BasicComponent.java BasicComponent.xprofile
               assembly/src/java/org/apache/excalibur/merlin/container
                        Container.java DefaultContainer.java
                        ProfileDesignator.java ProfileRegistry.java
                        ResourceProvider.java
               assembly/src/java/org/apache/excalibur/merlin/container/doc-files
                        Container.gif DefaultContainer.gif
               assembly/src/java/org/apache/excalibur/merlin/kernel
                        DefaultKernel.java
               assembly/src/java/org/apache/excalibur/merlin/model
                        ContextDirective.java Entry.java Parameter.java
               assembly/src/java/org/apache/excalibur/merlin/model/builder
                        XMLProfileCreator.java
  Added:       assembly/src/java/org/apache/excalibur/merlin/model
                        Import.java
  Log:
  addition of context import directives
  
  Revision  Changes    Path
  1.6       +6 -19     jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/BasicComponent.java
  
  Index: BasicComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/BasicComponent.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BasicComponent.java	18 Jul 2002 17:34:32 -0000	1.5
  +++ BasicComponent.java	19 Jul 2002 14:08:06 -0000	1.6
  @@ -26,29 +26,16 @@
   
       public void contextualize( Context context )
       {
  -        getLogger().info( "contextualization: " + context.getClass().getName() );
  -        try
  -        {
  -            m_location = (String) context.get("location");
  -        }
  -        catch( Throwable e )
  -        {
  -            getLogger().error("contextualization failure", e );
  -        }
  -        try
  -        {
  -            getLogger().info("home class: " + context.get("home").getClass().getName()
);
  -            m_home = (File) context.get("home");
  -        }
  -        catch( Throwable e )
  -        {
  -            getLogger().error("contextualization failure for home key", e );
  -        }
  +        BasicContextInterface c = (BasicContextInterface) context;
  +        m_location = c.getLocation();
  +        m_home = c.getWorkingDirectory();
       }
   
       public void initialize()
       {
  -        getLogger().info("initialize");
  +        getLogger().debug("initialize");
  +        getLogger().debug("location: " + m_location );
  +        getLogger().debug("home: " + m_home );
       }
   
       public void start()
  
  
  
  1.4       +3 -2      jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/BasicComponent.xprofile
  
  Index: BasicComponent.xprofile
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/BasicComponent.xprofile,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BasicComponent.xprofile	18 Jul 2002 17:34:32 -0000	1.3
  +++ BasicComponent.xprofile	19 Jul 2002 14:08:06 -0000	1.4
  @@ -3,7 +3,7 @@
   <profiles>
      
      <!-- 
  -   A packaged profile is equivalent to a compoent declaration inside a container, 
  +   A packaged profile is equivalent to a component declaration inside a container, 
      except that it is provided by a component type.  A PACKAGED profiles take priority
      over an IMPLICIT profile. An EXPLICIT profile declared inside a container defintion

      will take priority over PACKAGED profiles.
  @@ -11,8 +11,9 @@
    
      <component name="basic">
        <context class="org.apache.excalibur.playground.BasicContext">
  +       <import key="home" name="avalon:work"/>
          <entry key="location">Paris</entry>
  -       <entry key="home" class="java.io.File">../assembly</entry>
  +       <entry key="test" class="java.io.File">../assembly</entry>
        </context>
      </component>
   
  
  
  
  1.5       +24 -6     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/Container.java
  
  Index: Container.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/Container.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Container.java	18 Jul 2002 03:40:11 -0000	1.4
  +++ Container.java	19 Jul 2002 14:08:06 -0000	1.5
  @@ -31,7 +31,6 @@
    */
   public interface Container extends Controller, Verifiable
   {
  -
      /**
       * Assembly function that return an establish candidate resource from a parent or local
       * container matching a supplied profile.
  @@ -58,20 +57,39 @@
       String getPath();
   
      /**
  -    * Post-assembly function that returns the set of resources available in this 
  -    * container and all subsidary containers.
  +    * Post-assembly function that returns the set of resources 
  +    * available from the container.
       *
       * @return the set of available resources
       */
       ResourceDesignator[] getResources();
   
      /**
  -    * Post-assembly function that return the set of resources available in this 
  -    * container and all subsidary containers that match the supplied service type.
  +    * Post-assembly function that return the set of resources available in the 
  +    * container that matches the supplied service type.
       *
       * @param service the service type
       * @return the set of available resources matching the service type
       */
       ResourceDesignator[] getResources( ServiceDesignator service );
  +
  +   /**
  +    * <p>Post-assembly function that returns a resource by name.  The path
  +    * argument shall be in the form:</p>
  +    *
  +    * <pre>
  +    *    &lt;path&gt; == &lt;resource-type&gt; + ":" + &lt;container-path&gt;
+ "/" + &ltprofile-name&gt;
  +    *    &lt;container-path&gt; == &lt;parent-path&gt; + "/" + &lt;container-name&gt;
  +    *    &lt;parent-path&gt; == &lt;root&gt; | &lt;container-path&gt;
  +    * </pre>
  +    * <p><b>Example</b><p>
  +    * <pre>
  +    *   service:/facilities/security/vault
  +    * </pre>
  +    *
  +    * @param path the resource identifier
  +    * @return the named resource or null if the resource does not exist
  +    */
  +    ResourceDesignator getResource( String path );
   
   }
  
  
  
  1.12      +53 -6     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.java
  
  Index: DefaultContainer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultContainer.java	18 Jul 2002 03:40:11 -0000	1.11
  +++ DefaultContainer.java	19 Jul 2002 14:08:06 -0000	1.12
  @@ -122,6 +122,12 @@
       */
       public static final String CONTAINER_DESCRIPTOR_KEY = "descriptor";
   
  +   /**
  +    * Context key used to locate the logger manager.
  +    */
  +    public static final String DICTIONARY_KEY = "dictionary";
  +
  +
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultContainer.class );
   
  @@ -166,6 +172,11 @@
   
       private boolean m_initialized = false;
   
  +   /**
  +    * The context object against which resoruce requests will be evaluated.
  +    */
  +    private Context m_dictionary;
  +
       //=======================================================================
       // Contextualizable
       //=======================================================================
  @@ -179,6 +190,7 @@
           m_classloader = (ContainerClassLoader) context.get( CLASSLOADER_KEY );
           m_logging = (DefaultLoggerManager) context.get( LOG_MANAGER_KEY );
           m_descriptor = (ContainerDescriptor) context.get( CONTAINER_DESCRIPTOR_KEY );
  +        m_dictionary = (Context) context.get( DICTIONARY_KEY );
           try
           {
               m_parent = (Container) context.get( CONTAINER_KEY );
  @@ -208,7 +220,8 @@
       {
           getLogger().debug("initialization");
           m_helper.enableLogging( getLogger().getChildLogger("lifecycle") );
  -        m_provider = new ResourceProvider( m_classloader, m_logging, this );
  +        m_provider = new ResourceProvider( m_classloader, m_logging, this, m_dictionary
);
  +        m_provider.enableLogging( getLogger().getChildLogger("provider") );
   
           // 
           // initiate profile creation
  @@ -502,9 +515,44 @@
       }
   
      /**
  -    * Return the set of resources available in this container and all subsidary containers.
  +    * Returns a resource by name.
       *
  -    * @return the set of available resources
  +    * @param path the resource identifier
  +    * @return the named resource or null if the resource does not exist
  +    */
  +    public ResourceDesignator getResource( String path )
  +    {
  +        if( !m_initialized )
  +          throw new IllegalStateException("not-initialized");
  +
  +        //
  +        // if we have a parent container then let the parent handle the request
  +        // otherwise, we are the root container, in which case get the aggregated 
  +        // set of resources from the container hierachy and select the resoruce
  +        // by matching the name
  +        //
  +
  +        if( m_parent != null )
  +        {
  +            return m_parent.getResource( path );
  +        }
  +        else
  +        {
  +            ResourceDesignator[] resources = getResources();
  +            for( int i=0; i<resources.length; i++ )
  +            {
  +                final ResourceDesignator resource = resources[i];
  +                if( resource.getPath().equals( path ) )
  +                  return resource;
  +            }
  +            return null;
  +        }
  +    }
  +
  +   /**
  +    * Return the set of resources exported by this container.
  +    *
  +    * @return the set of exported resources
       */
       public ResourceDesignator[] getResources()
       {
  @@ -568,7 +616,6 @@
           }
       }
   
  -
      /**
       * Return the set of exportable services from this container.
       * @return the exporable service descriptors
  @@ -710,12 +757,12 @@
           context.put( MAP_KEY, map );
           context.put( LOG_MANAGER_KEY, m_logging );
           context.put( CONTAINER_DESCRIPTOR_KEY, descriptor );
  +        context.put( DICTIONARY_KEY, m_dictionary );
           context.makeReadOnly();
     
           DefaultContainer container = new DefaultContainer();
           container.enableLogging( logger );
           container.contextualize( context );
  -        //container.configure( config );
           container.initialize( );
           return container;
       }
  
  
  
  1.3       +4 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ProfileDesignator.java
  
  Index: ProfileDesignator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ProfileDesignator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProfileDesignator.java	18 Jul 2002 03:40:11 -0000	1.2
  +++ ProfileDesignator.java	19 Jul 2002 14:08:06 -0000	1.3
  @@ -20,6 +20,8 @@
   class ProfileDesignator implements ResourceDesignator
   {
   
  +    public static final String HEADER = "service:";
  +
       /**
        * The path of the profile designator.
        */
  @@ -88,7 +90,7 @@
        */
       public String getPath()
       {
  -        return m_path;
  +        return HEADER + m_path;
       }
   
       /**
  
  
  
  1.9       +3 -3      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ProfileRegistry.java
  
  Index: ProfileRegistry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ProfileRegistry.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ProfileRegistry.java	18 Jul 2002 03:40:11 -0000	1.8
  +++ ProfileRegistry.java	19 Jul 2002 14:08:06 -0000	1.9
  @@ -163,7 +163,7 @@
   
               final String name = m_path + "/" + profile.getName();
               m_mapping.put( profile, new ProfileDesignator( name, profile, m_helper, m_provider
) );
  -            getLogger().info( "created explicit resource for: " + name );
  +            getLogger().debug( "created explicit resource for: " + name );
               m_map.add( profile );
           }
       }
  @@ -231,7 +231,7 @@
                   {
                       resource = new ProfileDesignator( 
                         path, provider, m_helper, m_provider );
  -                    getLogger().info( "created dependent resource for: " + path );
  +                    getLogger().debug( "created dependent resource for: " + path );
                   }
                   profile.addProvider( role, resource );
                   if( isLocalProfile( provider ) ) 
  
  
  
  1.6       +42 -6     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ResourceProvider.java
  
  Index: ResourceProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ResourceProvider.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ResourceProvider.java	18 Jul 2002 16:57:00 -0000	1.5
  +++ ResourceProvider.java	19 Jul 2002 14:08:06 -0000	1.6
  @@ -29,7 +29,7 @@
   
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.excalibur.configuration.ConfigurationUtil;
  +import org.apache.avalon.framework.Version;
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.logger.AvalonFormatter;
  @@ -57,21 +57,22 @@
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.DefaultServiceManager;
   import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.avalon.framework.Version;
   import org.apache.avalon.excalibur.extension.PackageRepository;
   import org.apache.avalon.excalibur.extension.Extension;
   import org.apache.avalon.excalibur.extension.OptionalPackage;
   import org.apache.avalon.excalibur.extension.DefaultPackageRepository;
   import org.apache.excalibur.meta.verifier.VerifyException;
   import org.apache.excalibur.meta.info.Type;
  -import org.apache.excalibur.meta.info.Type;
   import org.apache.excalibur.meta.info.ServiceDescriptor;
   import org.apache.excalibur.meta.info.DependencyDescriptor;
   import org.apache.excalibur.meta.info.ServiceDesignator;
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.Association;
   import org.apache.excalibur.merlin.model.CategoryDescriptor;
  +import org.apache.excalibur.merlin.model.ResourceDesignator;
  +import org.apache.excalibur.merlin.model.Import;
   import org.apache.excalibur.merlin.kernel.DefaultLoggerManager;
  +import org.apache.excalibur.configuration.ConfigurationUtil;
   import org.apache.log.Hierarchy;
   import org.apache.log.Priority;
   import org.apache.log.output.io.StreamTarget;
  @@ -114,15 +115,19 @@
   
       private DefaultContainer m_locator;
   
  +    private Context m_dictionary;
  +
       //=======================================================================
       // constructor
       //=======================================================================
   
  -    public ResourceProvider( ClassLoader loader, DefaultLoggerManager manager, DefaultContainer
locator )
  +    public ResourceProvider( ClassLoader loader, DefaultLoggerManager manager, 
  +      DefaultContainer locator, Context dictionary )
       {
           m_classloader = loader;
           m_logging = manager;
           m_locator = locator;
  +        m_dictionary = dictionary;
       }
   
       //=======================================================================
  @@ -199,7 +204,38 @@
       public Context createContext( Profile profile )
           throws Exception
       {
  -        return profile.getContext().getContext( m_classloader, null );
  +        DefaultContext parent = new DefaultContext();
  +        Import[] imports = profile.getContext().getImports();
  +        getLogger().info( profile.getName() + " imports: " + imports.length );
  +        for( int i=0; i<imports.length; i++ )
  +        {
  +            Import directive = imports[i];
  +            final String name = directive.getImportName();
  +            final String key = directive.getKey();
  +            Object object = null;
  +
  +            try
  +            {
  +                object = m_dictionary.get( name );
  +                parent.put( key, object );
  +                getLogger().debug( 
  +                  "adding context entry: " + key 
  +                  + ", with name: " + name 
  +                  + ", and object: " + object );
  +            }
  +            catch( Throwable e )
  +            {
  +                final String error = 
  +                  "Could not resolve a value for the import directive in profile '" 
  +                      + profile.getName() 
  +                      + "' with the name '" + name
  +                      + "' for the key '" + key 
  +                      + "'.";
  +                throw new ContainerException( error );
  +            }
  +        }
  +
  +        return profile.getContext().getContext( m_classloader, parent );
       }
   
       /**
  
  
  
  1.3       +12 -10    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/doc-files/Container.gif
  
  	<<Binary file>>
  
  
  1.3       +46 -33    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/doc-files/DefaultContainer.gif
  
  	<<Binary file>>
  
  
  1.18      +13 -2     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.java
  
  Index: DefaultKernel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DefaultKernel.java	18 Jul 2002 03:40:11 -0000	1.17
  +++ DefaultKernel.java	19 Jul 2002 14:08:07 -0000	1.18
  @@ -86,6 +86,8 @@
       // static
       //=======================================================================
   
  +    public static final String AVALON_WORK_KEY = "avalon:work";
  +
       public static final String ROOT_CONTAINER_DESCRIPTOR_KEY = "descriptor";
       public static final String CLASSLOADER_KEY = "classloader";
       public static final String LOG_MANAGER_KEY = "logmanager";
  @@ -127,9 +129,9 @@
       */
       public void contextualize( Context context ) throws ContextException
       {
  -        m_descriptor = (ContainerDescriptor) context.get( ROOT_CONTAINER_DESCRIPTOR_KEY
);
           m_classloader = (ClassLoader) context.get( CLASSLOADER_KEY );
           m_logging = (DefaultLoggerManager) context.get( LOG_MANAGER_KEY );
  +        m_descriptor = (ContainerDescriptor) context.get( ROOT_CONTAINER_DESCRIPTOR_KEY
);
       }
   
       //=======================================================================
  @@ -173,6 +175,14 @@
           }
   
           //
  +        // dictionary creation
  +        //
  +
  +        DefaultContext dictionary = new DefaultContext();
  +        dictionary.put( AVALON_WORK_KEY, new File( System.getProperty("user.dir") ) );
  +        dictionary.makeReadOnly();
  +
  +        //
           // container context creation
           //
   
  @@ -181,6 +191,7 @@
           context.put( DefaultContainer.CLASSLOADER_KEY, loader );
           context.put( DefaultContainer.LOG_MANAGER_KEY, m_logging );
           context.put( DefaultContainer.CONTAINER_DESCRIPTOR_KEY, m_descriptor );
  +        context.put( DefaultContainer.DICTIONARY_KEY, dictionary );
           context.makeReadOnly();
   
           //
  
  
  
  1.2       +32 -17    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/ContextDirective.java
  
  Index: ContextDirective.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/ContextDirective.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContextDirective.java	18 Jul 2002 16:57:00 -0000	1.1
  +++ ContextDirective.java	19 Jul 2002 14:08:07 -0000	1.2
  @@ -25,9 +25,9 @@
    * 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 key="<font color="darkred">avalon.work</font>" as="base"/&gt;
  - *       &lt;entry key="<font color="darkred">location</font>" value="Paris"/&gt;
  - *    <font color="gray">&lt;/context&gt;</font>
  + *       &lt;import key="<font color="darkred">avalon.work</font>" as="<font
color="darkred">base</font>"/&gt;
  + *       &lt;entry key="<font color="darkred">location</font>" value="<font
color="darkred">Paris</font>"/&gt;
  + *    &lt;/context&gt;
    * </pre>
    *
    * @see Entry
  @@ -46,6 +46,11 @@
       private final Entry[] m_entries;
   
      /**
  +    * The set of import directives.
  +    */
  +    private final Import[] m_imports;
  +
  +   /**
       * The set of entry directives.
       */
       private final String m_classname;
  @@ -56,23 +61,22 @@
       private Context m_context;
   
      /**
  -    * Creation of a new context directive.
  -    * @param location the filename of the logging destination
  -    */
  -    public ContextDirective( final Entry[] entries )
  -    {
  -        this( DEFAULT_CONTEXT_CLASS, entries );
  -    }
  -
  -   /**
       * Creation of a new file target.
       * @param classname the context implementation class
  -    * @param parameters the context implementation constructor arguments
  -    * @param entries the context entry descriptors
  +    * @param imports the set of import directives
  +    * @param entries the set of entry descriptors
       */
  -    public ContextDirective( final String classname, final Entry[] entries )
  +    public ContextDirective( final String classname, final Import[] imports, final Entry[]
entries )
       {
  -        m_classname = classname;
  +        if( classname != null )
  +        {
  +            m_classname = classname;
  +        }
  +        else
  +        {
  +            m_classname = DEFAULT_CONTEXT_CLASS; 
  +        }
  +        m_imports = imports;
           m_entries = entries;
       }
   
  @@ -95,9 +99,19 @@
       }
   
      /**
  +    * Return the set of import directives.
  +    * @return the imports
  +    */
  +    public Import[] getImports()
  +    {
  +        return m_imports;
  +    }
  +
  +   /**
       * Returns the context object based on the context directives.
       * @param parent a possibly null parent context
       * @return the context object
  +    * @exception ModelException if a context instantiation error occurs
       */
       public Context getContext( ClassLoader loader, Context parent ) throws ModelException
       {
  @@ -152,6 +166,7 @@
           {
               ((DefaultContext)m_context).makeReadOnly();
           }
  +
           return m_context;
       }
   }
  
  
  
  1.3       +4 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Entry.java
  
  Index: Entry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Entry.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Entry.java	18 Jul 2002 17:34:33 -0000	1.2
  +++ Entry.java	19 Jul 2002 14:08:07 -0000	1.3
  @@ -16,12 +16,14 @@
    * <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>
    * <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;parameter class="<font color="darkred">java.io.File</font>"&gt;<font
color="darkred">../home</font>&lt/parameter&gt;
    *    &lt;/entry&gt; 
  + *  <font color="gray">&lt;/context&gt;</font>
    * </pre>
    *
    * @see Parameter
  
  
  
  1.3       +5 -5      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Parameter.java
  
  Index: Parameter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Parameter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Parameter.java	18 Jul 2002 17:34:33 -0000	1.2
  +++ Parameter.java	19 Jul 2002 14:08:07 -0000	1.3
  @@ -19,19 +19,19 @@
    * <p><b>XML</b></p>
    * <p>A parameter is a nested structure containing a string value or contructor parameter
arguments.</p>
    * <pre>
  - *    <font color="gray">&lt;-- Simple parameter declaration --&gt;</font>
  + *    <font color="gray">&lt;-- Simple string parameter declaration --&gt;</font>
    *
  - *    &lt;parameter&gt;<font color="darkred">London</font>"/parameter&gt;
  + *    &lt;parameter&gt;<font color="darkred">London</font>&lt;/parameter&gt;
    *
    *    <font color="gray">&lt;-- Typed parameter declaration --&gt;</font>
    *
    *    &lt;parameter class="<font color="darkred">java.io.File</font>"&gt;<font
color="darkred">./home</font>&lt;/parameter&gt;
    *
  - *    <font color="gray">&lt;-- Multi-argument constructor parameter declaration
--&gt;</font>
  + *    <font color="gray">&lt;-- Multi-argument parameter declaration --&gt;</font>
    * 
    *    &lt;parameter class="<font color="darkred">MyClass</font>"&gt;
    *       &lt;parameter class="<font color="darkred">java.io.File</font>"><font
color="darkred">./home</font>&lt;/parameter&gt;
  - *       &lt;parameter&gt;<font color="darkred">London</font>"/&gt;
  + *       &lt;parameter&gt;<font color="darkred">London</font>&lt;/parameter&gt;
    *    &lt;/parameter&gt;
    * </pre>
    *
  
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Import.java
  
  Index: Import.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.merlin.model;
  
  
  /**
   * An inport directive used within a context directive to request a container scoped values.
   * 
   * <p><b>XML</b></p>
   * <p>An import statement declares that a context value must be supplied by the container,

   * using the container scoped value of the <code>name</code> attribute, and
that the value should be 
   * supplied as a context entry keyed under the value of the <code>key</code>
attribute.</p>
   * <pre>
   *
   *    <font color="gray">
   *    &lt;-- 
   *    Declare the import of the value of avalon.work as a keyed context
   *    value using the key "home".
   *    --&gt;</font>
   *
   *  <font color="gray">&lt;context&gt;</font>
   *    &lt;import key="<font color="darkred">home</font>" resource="<font
color="darkred">avalon.home</font>"&gt;;
   *  <font color="gray">&lt;/context&gt;</font>
   * </pre>
   *
   * @see ContextDirective
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2002/07/19 14:08:07 $
   */
  public class Import 
  {
     /**
      * The local key.
      */
      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
      */
      public Import( final String key, final String name )
      {
          if( null == key )
            throw new NullPointerException("key");
  
          if( null == name )
            throw new NullPointerException("name");
  
          m_key = key;
          m_name = name;
      }
  
     /**
      * Returns the key of the context entry to import.
      * @return the import key value
      */
      public String getImportName()
      {
          return m_name;
      }
  
     /**
      * Return the key that will be used by a client of a context object to 
      * access the inported value.
      *
      * @return the local context key
      */
      public String getKey()
      {
          return m_key;
      }
  }
  
  
  
  1.7       +23 -3     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLProfileCreator.java
  
  Index: XMLProfileCreator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLProfileCreator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLProfileCreator.java	18 Jul 2002 17:34:33 -0000	1.6
  +++ XMLProfileCreator.java	19 Jul 2002 14:08:07 -0000	1.7
  @@ -25,6 +25,7 @@
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.CategoryDescriptor;
   import org.apache.excalibur.merlin.model.ContextDirective;
  +import org.apache.excalibur.merlin.model.Import;
   import org.apache.excalibur.merlin.model.Entry;
   import org.apache.excalibur.merlin.model.Parameter;
   import org.apache.excalibur.configuration.ContextFactory;
  @@ -83,7 +84,8 @@
   
               CategoryDescriptor loggers = new CategoryDescriptor( 
                 type.getInfo().getName(), null, null );
  -            ContextDirective context = new ContextDirective( new Entry[0] );
  +            ContextDirective context = new ContextDirective( 
  +              ContextDirective.DEFAULT_CONTEXT_CLASS, new Import[0], new Entry[0] );
   
               return new Profile[]{ 
                  new Profile( null, null, null, context, loggers, type, true, Profile.IMPLICIT
 ) };
  @@ -116,8 +118,26 @@
       public ContextDirective createContextDirective( Configuration config ) throws ConfigurationException
       {
           String classname = config.getAttribute( "class", ContextDirective.DEFAULT_CONTEXT_CLASS
);
  +        Import[] imports = createImports( config.getChildren("import") );
           Entry[] entries = createEntries( config.getChildren("entry") );
  -        return new ContextDirective( classname, entries );
  +        return new ContextDirective( classname, imports, entries );
  +    }
  +
  +    public Import[] createImports( Configuration[] configs ) throws ConfigurationException
  +    {
  +        ArrayList list = new ArrayList();
  +        for( int i=0; i<configs.length; i++ )
  +        {
  +            list.add( createImport( configs[i] ) );
  +        }
  +        return (Import[]) list.toArray( new Import[0] );
  +    }
  +
  +    public Import createImport( Configuration config ) throws ConfigurationException
  +    {
  +        final String key = config.getAttribute( "key" );
  +        final String path = config.getAttribute( "name" );
  +        return new Import( key, path );
       }
   
       public Entry[] createEntries( Configuration[] configs ) 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>


Mime
View raw message