You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2003/04/20 14:26:27 UTC

cvs commit: avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/model/builder ProfileCreator.java XMLProfileCreator.java

mcconnell    2003/04/20 05:26:27

  Modified:    merlin/meta/src/java/org/apache/avalon/meta/model/builder
                        ProfileCreator.java XMLProfileCreator.java
  Log:
  Updated to improve handling of profile construction (resulting from ContainementProfile updates).
  
  Revision  Changes    Path
  1.2       +13 -1     avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/model/builder/ProfileCreator.java
  
  Index: ProfileCreator.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/model/builder/ProfileCreator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProfileCreator.java	13 Mar 2003 01:06:06 -0000	1.1
  +++ ProfileCreator.java	20 Apr 2003 12:26:27 -0000	1.2
  @@ -89,4 +89,16 @@
       Profile createProfile( Type type, Configuration config )
           throws Exception;
   
  +    /**
  +     * Create an explicit {@link Profile} instances from a configuration
  +     * using a set of type defaults
  +     *
  +     * @param type the component type
  +     * @param config the profile description
  +     * @param defaults a default configuration
  +     * @return the profile
  +     * @exception Exception if an error occurs during profile creation
  +     */
  +    Profile createProfile( Type type, Configuration config, Configuration defaults  )
  +        throws Exception;
   }
  
  
  
  1.2       +39 -5     avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/model/builder/XMLProfileCreator.java
  
  Index: XMLProfileCreator.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta/src/java/org/apache/avalon/meta/model/builder/XMLProfileCreator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLProfileCreator.java	13 Mar 2003 01:06:07 -0000	1.1
  +++ XMLProfileCreator.java	20 Apr 2003 12:26:27 -0000	1.2
  @@ -74,6 +74,7 @@
   import org.apache.avalon.meta.ConfigurationBuilder;
   import org.apache.avalon.meta.info.Type;
   import org.apache.avalon.meta.info.builder.XMLTypeCreator;
  +import org.apache.excalibur.configuration.CascadingConfiguration;
   import org.xml.sax.InputSource;
   
   /**
  @@ -113,7 +114,8 @@
       * Creation of a profile builder that uses the supplied base class for
       * new profile creation.
       * @param base the profile base class
  -    * @exception RuntimeException if the supplied base class has an incompatible constructor
  +    * @exception RuntimeException if the supplied base class has an 
  +    *   incompatible constructor
       */
       public XMLProfileCreator( Class base )
       {
  @@ -187,10 +189,26 @@
       public Profile createProfile( Type type, Configuration config )
           throws Exception
       {
  -        return buildProfile( type, config, Mode.EXPLICIT );
  +        return createProfile( type, config, null );
       }
   
       /**
  +     * Create an explicit {@link Profile} instances from a configuration
  +     * using a set of type defaults
  +     *
  +     * @param type the component type
  +     * @param config the profile description
  +     * @param defaults a default configuration
  +     * @return the profile
  +     * @exception Exception if an error occurs during profile creation
  +     */
  +    public Profile createProfile( 
  +      Type type, Configuration config, Configuration defaults  )
  +        throws Exception
  +    {
  +        return buildProfile( type, config, defaults, Mode.EXPLICIT );
  +    }
  +    /**
        * Create an array of {@link Profile} object for specified type from
        * specified configuration data associated with a single type.
        *
  @@ -225,6 +243,13 @@
           Type type, Configuration profile, Mode mode )
           throws Exception
       {
  +        return buildProfile( type, profile, null, mode );
  +    }
  +
  +    private Profile buildProfile(
  +        Type type, Configuration profile, Configuration defaults, Mode mode )
  +        throws Exception
  +    {
   
           //
           // create the logging categories for this profile
  @@ -244,8 +269,17 @@
               Parameters.fromConfiguration( profile.getChild( "parameters" ) );
           final ContextDirective context =
               createContextDirective( profile.getChild( "context" ) );
  -        final Configuration config =
  -            profile.getChild( "configuration" );
  +
  +        Configuration config = null;
  +        if( defaults == null )
  +        {
  +            config = profile.getChild( "configuration" );
  +        }
  +        else
  +        {
  +            Configuration base = profile.getChild( "configuration" );
  +            config = new CascadingConfiguration( defaults, base );
  +        }
   
           //
           // create the profile instance
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org