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 ProfileCreator.java XMLProfileCreator.java
Date Fri, 02 Aug 2002 06:34:52 GMT
mcconnell    2002/08/01 23:34:52

  Modified:    assembly/src/java/org/apache/excalibur/merlin/model
                        CategoriesDescriptor.java Category.java
                        ContextDirective.java Import.java Profile.java
                        Resource.java
               assembly/src/java/org/apache/excalibur/merlin/model/builder
                        ProfileCreator.java XMLProfileCreator.java
  Added:       assembly/src/java/org/apache/excalibur/merlin/model
                        ClasspathDescriptor.java ContainerDescriptor.java
                        DirsetDescriptor.java ExtensionsDescriptor.java
                        FileTargetProvider.java FilesetDescriptor.java
                        IncludeDescriptor.java KernelDescriptor.java
                        LoggingDescriptor.java TargetDescriptor.java
                        TargetProvider.java
  Log:
  rationalizing model components
  
  Revision  Changes    Path
  1.2       +11 -1     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/CategoriesDescriptor.java
  
  Index: CategoriesDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/CategoriesDescriptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CategoriesDescriptor.java	25 Jul 2002 18:04:58 -0000	1.1
  +++ CategoriesDescriptor.java	2 Aug 2002 06:34:51 -0000	1.2
  @@ -37,6 +37,16 @@
        * Create a CategoriesDescriptor instance.
        *
        * @param name the base category name
  +     */
  +    public CategoriesDescriptor( final String name )
  +    {
  +        this( name, null, null, new Category[0] );
  +    }
  +
  +    /**
  +     * Create a CategoriesDescriptor instance.
  +     *
  +     * @param name the base category name
        * @param priority the default logging priority
        * @param target the default logging target
        * @param categories the logging category descriptors
  
  
  
  1.4       +11 -1     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Category.java
  
  Index: Category.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Category.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Category.java	29 Jul 2002 06:14:32 -0000	1.3
  +++ Category.java	2 Aug 2002 06:34:51 -0000	1.4
  @@ -59,6 +59,16 @@
       private final String m_target;
   
       /**
  +     * Creation of a new Category using a supplied name.
  +     *
  +     * @param name the category name
  +     */
  +    public Category( final String name )
  +    {
  +        this( name, null, null );
  +    }
  +
  +    /**
        * Creation of a new Category using a supplied name, priority, target and 
        * collection of subsidiary categories. 
        *
  
  
  
  1.6       +2 -2      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ContextDirective.java	23 Jul 2002 15:36:04 -0000	1.5
  +++ ContextDirective.java	2 Aug 2002 06:34:51 -0000	1.6
  @@ -26,7 +26,7 @@
    * <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">avalon.work</font>" key="<font
color="darkred">base</font>"/&gt;
  + *       &lt;import name="<font color="darkred">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;
  
  
  
  1.5       +3 -3      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Import.java
  
  Index: Import.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Import.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Import.java	30 Jul 2002 07:05:55 -0000	1.4
  +++ Import.java	2 Aug 2002 06:34:51 -0000	1.5
  @@ -19,12 +19,12 @@
    *
    *    <font color="gray">
    *    &lt;-- 
  - *    Declare the import of the value of "avalon.work" as a keyed context
  + *    Declare the import of the value of "avalon:home" 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>" name="<font
color="darkred">avalon.home</font>"&gt;;
  + *    &lt;import key="<font color="darkred">home</font>" name="<font
color="darkred">avalon:home</font>"&gt;;
    *  <font color="gray">&lt;/context&gt;</font>
    * </pre>
    *
  
  
  
  1.14      +88 -5     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Profile.java
  
  Index: Profile.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Profile.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Profile.java	30 Jul 2002 13:49:08 -0000	1.13
  +++ Profile.java	2 Aug 2002 06:34:51 -0000	1.14
  @@ -7,17 +7,22 @@
    */
   package org.apache.excalibur.merlin.model;
   
  +import java.io.InputStream;
   import java.io.Serializable;
   import java.util.Hashtable;
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.context.Context;
  +import org.apache.excalibur.meta.ConfigurationBuilder;
   import org.apache.excalibur.meta.info.Type;
   import org.apache.excalibur.meta.info.Facility;
   import org.apache.excalibur.meta.info.PhaseDescriptor;
   import org.apache.excalibur.merlin.model.Association;
   import org.apache.excalibur.configuration.ConfigurationUtil;
  +import org.apache.excalibur.configuration.CascadingConfiguration;
  +import org.xml.sax.InputSource;
   
   /**
    * Defintion of the criteria for an explicit component profile.  A profile, when 
  @@ -151,6 +156,11 @@
       private final Configuration m_configuration;
   
       /**
  +     * The derived configuration
  +     */
  +    private Configuration m_config;
  +
  +    /**
        * The configuration for component (if any).
        */
       private final ContextDirective m_context;
  @@ -302,14 +312,73 @@
       /**
        * Return the Configuration for the profile.
        *
  -     * @return the Configuration for profile.
  +     * @return the base Configuration for profile.
        */
  -    public Configuration getConfiguration()
  +    public Configuration getConfiguration( )
       {
           return m_configuration;
       }
   
       /**
  +     * Return the derived Configuration for the profile.
  +     *
  +     * @return the Configuration for profile.
  +     */
  +    public Configuration getConfiguration( ClassLoader classloader ) throws Exception
  +    {
  +        if( m_config != null )
  +          return m_config;
  +
  +        final Configuration defaults = getType().getDefaultConfiguration( classloader );
  +        Configuration base = null;
  +        if( getConfiguration().getAttribute("src", null ) != null )
  +        {
  +            String src = getConfiguration().getAttribute("src" );
  +            if( src.startsWith("resource://") )
  +            {
  +                final String url = src.substring( 11 );
  +                final InputStream stream =
  +                 classloader.getResourceAsStream( url );
  +                if( null == stream )
  +                {
  +                    final String error =
  +                     "Requested configuration source does not exist: " + src;
  +                    throw new ConfigurationException( error );
  +                }
  +                final InputSource source = new InputSource( stream );
  +                base = ConfigurationBuilder.build( source );
  +            }
  +            else
  +            {
  +                try
  +                {
  +                    base = ConfigurationBuilder.build( src );
  +                }
  +                catch( Throwable e )
  +                {
  +                    final String error =
  +                     "Unexpected exception while attempting to resolve configuration fro
src : " + src;
  +                    throw new ConfigurationException( error );
  +                }
  +            }
  +        }
  +        else
  +        {
  +            base = getConfiguration();
  +        }
  +
  +        if( null == defaults )
  +        {
  +            m_config = base;
  +        }
  +        else
  +        {
  +            m_config = new CascadingConfiguration( base, defaults );
  +        }
  +        return m_config;
  +    }
  +
  +    /**
        * Return the dependency associations for component type with specified role.
        *
        * @return the dependency metadata for component with specified role.
  @@ -368,8 +437,22 @@
       */
       public Facility getFacility( PhaseDescriptor phase )
       {
  -        Profile profile = (Profile) m_extensions.get( phase );
  -        return (Facility) profile.getType();
  +        Profile profile = getExtensionProfile( phase );
  +        if( profile != null )
  +        {
  +            return (Facility) profile.getType();
  +        }
  +        return null;
  +    }
  +
  +   /**
  +    * Return the profile associated as the phase provider.
  +    * @param phase the lifecycle phase specification
  +    * @return a reference to the phase extension
  +    */
  +    public Profile getExtensionProfile( PhaseDescriptor phase )
  +    {
  +        return (Profile) m_extensions.get( phase );
       }
   
   
  
  
  
  1.3       +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Resource.java
  
  Index: Resource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Resource.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Resource.java	30 Jul 2002 14:34:04 -0000	1.2
  +++ Resource.java	2 Aug 2002 06:34:51 -0000	1.3
  @@ -67,7 +67,7 @@
       /**
        * Release the service instance.
        */
  -    public void release( Object instance );
  +    public void release( Object instance ) throws Exception;
   
       /**
        * Destroy the resource.
  
  
  
  1.5       +11 -4     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/ClasspathDescriptor.java
  
  
  
  
  1.10      +77 -52    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/ContainerDescriptor.java
  
  
  
  
  1.5       +1 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/DirsetDescriptor.java
  
  
  
  
  1.5       +1 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/ExtensionsDescriptor.java
  
  
  
  
  1.5       +1 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/FileTargetProvider.java
  
  
  
  
  1.5       +1 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/FilesetDescriptor.java
  
  
  
  
  1.6       +1 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/IncludeDescriptor.java
  
  
  
  
  1.8       +15 -12    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/KernelDescriptor.java
  
  
  
  
  1.8       +10 -1     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/LoggingDescriptor.java
  
  
  
  
  1.5       +1 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/TargetDescriptor.java
  
  
  
  
  1.5       +1 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/TargetProvider.java
  
  
  
  
  1.5       +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ProfileCreator.java
  
  Index: ProfileCreator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ProfileCreator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ProfileCreator.java	29 Jul 2002 06:14:33 -0000	1.4
  +++ ProfileCreator.java	2 Aug 2002 06:34:51 -0000	1.5
  @@ -39,7 +39,7 @@
        * @return the profile
        * @exception Exception if an error occurs during profile creation
        */
  -    Profile createProfile( ClassLoader loader, Type type, Configuration config )
  +    Profile createProfile( Type type, Configuration config )
           throws Exception;
   
   }
  
  
  
  1.12      +12 -69    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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XMLProfileCreator.java	29 Jul 2002 06:14:33 -0000	1.11
  +++ XMLProfileCreator.java	2 Aug 2002 06:34:51 -0000	1.12
  @@ -16,6 +16,7 @@
   import org.apache.avalon.framework.Version;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  @@ -42,7 +43,7 @@
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
    * @version $Revision$ $Date$
    */
  -public class XMLProfileCreator
  +public class XMLProfileCreator 
       implements ProfileCreator
   {
       private static final Resources REZ =
  @@ -70,7 +71,7 @@
           }
           else
           {
  -            Profile profile = createImplicitProfile( loader, type );
  +            Profile profile = createImplicitProfile( type );
               return new Profile[]{ profile };
           }
       }
  @@ -82,11 +83,10 @@
        * @return the profile
        * @exception Exception if an error occurs during profile creation
        */
  -    public Profile createProfile( 
  -      ClassLoader loader, Type type, Configuration config )
  +    public Profile createProfile( Type type, Configuration config )
         throws Exception
       {
  -        return buildProfile( loader, type, config, Profile.EXPLICIT );
  +        return buildProfile( type, config, Profile.EXPLICIT );
       }
   
       /**
  @@ -106,18 +106,17 @@
           Configuration[] profiles = info.getChildren("component");
           if( profiles.length == 0 )
           {
  -            Profile profile = createImplicitProfile( loader, type );
  +            Profile profile = createImplicitProfile( type );
               return new Profile[]{ profile };
           }
           for( int i=0; i<profiles.length; i++ )
           {
  -           vector.add( buildProfile( loader, type, profiles[i], Profile.PACKAGED ) );
  +           vector.add( buildProfile( type, profiles[i], Profile.PACKAGED ) );
           }
           return (Profile[]) vector.toArray( new Profile[0] );
       }
   
  -    private Profile buildProfile( 
  -      ClassLoader loader, Type type, Configuration profile, int mode ) 
  +    private Profile buildProfile( Type type, Configuration profile, int mode ) 
         throws Exception
       {
   
  @@ -129,8 +128,6 @@
           final String name = profile.getAttribute("name");
           CategoriesDescriptor categories = 
             createCategoriesDescriptor( name, profile.getChild("categories") );
  -        //container.addCategories( categories );
  -        //logger = container.getLogger().getChildLogger( name );
   
           //
           // build the profile directives
  @@ -140,8 +137,7 @@
           final boolean activation = profile.getAttributeAsBoolean( "activation", false );
           final Parameters params = Parameters.fromConfiguration( profile.getChild("parameters")
);
           final ContextDirective context = createContextDirective( profile.getChild("context")
);
  -        final Configuration config = 
  -          createConfiguration( loader, type, profile.getChild("configuration") ); 
  +        final Configuration config = profile.getChild("configuration");
   
           //
           // create the profile instance
  @@ -150,58 +146,6 @@
           return new Profile( name, params, config, context, categories, type, enabled, activation,
mode  );
       }
   
  -    public Configuration createConfiguration( ClassLoader loader, Type type, Configuration
config ) 
  -      throws Exception
  -    {
  -        final Configuration defaults = type.getDefaultConfiguration( loader );
  -        Configuration base = null;
  -        if( config.getAttribute("src", null ) != null )
  -        {
  -            String src = config.getAttribute("src" );
  -            if( src.startsWith("resource://") )
  -            {
  -                final String url = src.substring( 11 );
  -                final InputStream stream =
  -                 loader.getResourceAsStream( url );
  -                if( null == stream )
  -                {
  -                    final String error =
  -                     "Requested configuration source does not exist: " + src;
  -                    throw new ConfigurationException( error );
  -                }
  -                final InputSource source = new InputSource( stream );
  -                base = ConfigurationBuilder.build( source );
  -            }
  -            else
  -            {
  -                try
  -                {
  -                    base = ConfigurationBuilder.build( src );
  -                }
  -                catch( Throwable e )
  -                {
  -                    final String error =
  -                     "Unexpected exception while attempting to resolve configuration fro
src : " + src;
  -                    throw new ConfigurationException( error );
  -                }
  -            }
  -        }
  -        else
  -        {
  -            base = config;
  -        }
  -
  -        if( null == defaults )
  -        {
  -            return base;
  -        }
  -        else
  -        {
  -            return new CascadingConfiguration( base, defaults );
  -        }
  -    }
  -    
  -
       public ContextDirective createContextDirective( Configuration config ) throws ConfigurationException
       {
           String classname = config.getAttribute( "class", ContextDirective.DEFAULT_CONTEXT_CLASS
);
  @@ -307,12 +251,11 @@
           return new Category( name, priority, target );
       }
   
  -    private Profile createImplicitProfile( 
  -      ClassLoader loader, Type type ) throws Exception
  +    private Profile createImplicitProfile( Type type ) throws Exception
       {
           ContextDirective context = new ContextDirective( 
             ContextDirective.DEFAULT_CONTEXT_CLASS, new Import[0], new Entry[0] );
  -        final Configuration defaults = type.getDefaultConfiguration( loader );
  +        final Configuration defaults = new DefaultConfiguration("default",null);
           final CategoriesDescriptor categories = createDefaultCategoriesDescriptor( type
);
   
           return new Profile( 
  
  
  

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