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/resource DeploymentHelper.java ThreadLocalLifestyleHandler.java
Date Mon, 18 Nov 2002 10:52:54 GMT
mcconnell    2002/11/18 02:52:54

  Modified:    assembly/src/java/org/apache/excalibur/merlin/assembly
                        ContainerManager.java DefaultLoggerManager.java
                        DefaultSelector.java Selector.java
               assembly/src/java/org/apache/excalibur/merlin/container
                        ContainerFactory.java ContainerHelper.java
                        ContainerResource.java DefaultContainer.java
               assembly/src/java/org/apache/excalibur/merlin/kernel
                        DefaultKernel.java
               assembly/src/java/org/apache/excalibur/merlin/model
                        ContainerDescriptor.java LoggingDescriptor.java
                        Profile.java Resource.java
               assembly/src/java/org/apache/excalibur/merlin/model/builder
                        ContainerBuilder.java XMLContainerCreator.java
               assembly/src/java/org/apache/excalibur/merlin/model/verifier
                        AssemblyVerifier.java
               assembly/src/java/org/apache/excalibur/merlin/resource
                        DeploymentHelper.java
                        ThreadLocalLifestyleHandler.java
  Log:
  Updates to complete seperation of profile abstraction and refactoring
  to user the excalibur/meta/model classes in preference to local content.
  
  Revision  Changes    Path
  1.42      +48 -24    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ContainerManager.java
  
  Index: ContainerManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ContainerManager.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- ContainerManager.java	24 Oct 2002 04:12:43 -0000	1.41
  +++ ContainerManager.java	18 Nov 2002 10:52:53 -0000	1.42
  @@ -68,17 +68,23 @@
   import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.logger.LogEnabled;
   import org.apache.avalon.framework.logger.Logger;
  +import org.apache.excalibur.meta.info.Type;
  +import org.apache.excalibur.meta.info.DependencyDescriptor;
  +import org.apache.excalibur.meta.info.ExtensionDescriptor;
  +import org.apache.excalibur.meta.info.ReferenceDescriptor;
  +import org.apache.excalibur.meta.info.ServiceDescriptor;
  +import org.apache.excalibur.meta.info.StageDescriptor;
  +import org.apache.excalibur.meta.model.LoggingDirective;
  +import org.apache.excalibur.merlin.model.Profile;
  +import org.apache.excalibur.meta.model.builder.ProfileBuilder;
   import org.apache.excalibur.merlin.container.Container;
   import org.apache.excalibur.merlin.container.ContainerResource;
   import org.apache.excalibur.merlin.model.Association;
  -import org.apache.excalibur.merlin.model.CategoriesDescriptor;
   import org.apache.excalibur.merlin.model.ClasspathDescriptor;
   import org.apache.excalibur.merlin.model.ContainerDescriptor;
   import org.apache.excalibur.merlin.model.LoggingDescriptor;
  -import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.Resource;
   import org.apache.excalibur.merlin.model.builder.ContainerBuilder;
  -import org.apache.excalibur.merlin.model.builder.ProfileBuilder;
   import org.apache.excalibur.merlin.model.builder.XMLContainerCreator;
   import org.apache.excalibur.merlin.resource.DefaultResource;
   import org.apache.excalibur.merlin.resource.DeploymentHelper;
  @@ -87,12 +93,6 @@
   import org.apache.excalibur.merlin.resource.LifestyleManager;
   import org.apache.excalibur.merlin.resource.ResourceException;
   import org.apache.excalibur.merlin.resource.ResourceFactory;
  -import org.apache.excalibur.meta.info.DependencyDescriptor;
  -import org.apache.excalibur.meta.info.ExtensionDescriptor;
  -import org.apache.excalibur.meta.info.ReferenceDescriptor;
  -import org.apache.excalibur.meta.info.ServiceDescriptor;
  -import org.apache.excalibur.meta.info.StageDescriptor;
  -import org.apache.excalibur.meta.info.Type;
   
   /**
    * Classloader for an assembly of components that provides the complete
  @@ -133,6 +133,9 @@
        */
       public static final String LIFESTYLES_KEY = "lifestyles";
   
  +    private static final Class PROFILE_CLASS = 
  +      org.apache.excalibur.merlin.model.Profile.class;
  +
       //===================================================================
       // state
       //===================================================================
  @@ -160,12 +163,12 @@
       /**
        * Utility class used to create component profile meta data.
        */
  -    private ProfileBuilder m_builder = new ProfileBuilder();
  +    private ProfileBuilder m_builder;
   
       /**
        * Utility class used to create container profile meta data.
        */
  -    private ContainerBuilder m_containerBuilder = new ContainerBuilder();
  +    private ContainerBuilder m_containerBuilder;
   
       /**
        * Utility class that manages supply of context, config, services, etc. during
  @@ -326,11 +329,12 @@
       {
           super.initialize();
   
  +        m_builder = new ProfileBuilder( PROFILE_CLASS );
  +        m_containerBuilder = new ContainerBuilder();
  +
           m_deployment = new DeploymentHelper( getLoggingManager(), this );
           m_deployment.enableLogging( getLocalLogger().getChildLogger( "deployment" ) );
   
  -        XMLContainerCreator creator = new XMLContainerCreator();
  -
           getLogger().debug(
               "creating manager '" + m_name
               + "' " + System.identityHashCode( this )
  @@ -363,7 +367,7 @@
               String classname = type.getInfo().getImplementationKey();
               Class clazz = loadClass( classname );
   
  -            Profile[] profiles;
  +            Object[] profiles;
               if( Container.class.isAssignableFrom( clazz ) )
               {
                   profiles = m_containerBuilder.build( this, type );
  @@ -375,7 +379,17 @@
   
               for( int j = 0; j < profiles.length; j++ )
               {
  -                addProfile( profiles[ j ] );
  +                Object profile = profiles[j];
  +                if( profile instanceof Profile )
  +                {
  +                    addProfile( (Profile) profile );
  +                }
  +                else
  +                {
  +                    final String error = "Created profile is not derived from class: " 
  +                      + Profile.class.getName();
  +                    throw new ClassCastException( error );
  +                }
               }
           }
       }
  @@ -554,7 +568,7 @@
               path = getPath().replace( '/', '.' ).substring( 1 ) + "." + name;
           }
   
  -        CategoriesDescriptor categories = descriptor.getCategories();
  +        LoggingDirective categories = descriptor.getCategories();
           getLoggingManager().addCategories( path, categories );
   
   
  @@ -780,7 +794,7 @@
       public Profile getProfile( StageDescriptor phase )
       {
           Profile[] profiles = getProfiles( phase );
  -        return getSelector( phase ).select( profiles );
  +        return (Profile) getSelector( phase ).select( profiles );
       }
   
       /**
  @@ -828,7 +842,7 @@
           }
   
           Profile[] profiles = getProfiles( reference );
  -        return selector.select( profiles );
  +        return (Profile) selector.select( profiles );
       }
   
       /**
  @@ -972,7 +986,6 @@
               try
               {
                   Resource factoryResource = assemble( factoryProfile, c );
  -                Association[] associations = factoryProfile.getAssociations();
                   ResourceFactory factory = (ResourceFactory)factoryResource.access();
                   Resource res = factory.createResource( this, profile, c, handler );
                   m_resources.put( profile, res );
  @@ -995,14 +1008,25 @@
               //
   
               Resource res;
  -            if( profile instanceof ContainerDescriptor )
  +
  +            try
               {
  -                res = new ContainerResource( this, profile, c, handler );
  +                if( Container.class.isAssignableFrom( 
  +                  loadClass( profile.getType().getInfo().getImplementationKey() ) ) )
  +                {
  +                    res = new ContainerResource( this, (ContainerDescriptor) profile, c, handler );
  +                }
  +                else
  +                {
  +                    res = new DefaultResource( this, profile, c, handler );
  +                }
               }
  -            else
  +            catch( Throwable e )
               {
  -                res = new DefaultResource( this, profile, c, handler );
  +                final String error = "Error establishing container resource for profile: " + profile;
  +                throw new AssemblyRuntimeException( error, e );
               }
  +
               ( (LogEnabled)res ).enableLogging( getLocalLogger().getChildLogger( "resource" ) );
               m_resources.put( profile, res );
               return res;
  
  
  
  1.16      +4 -4      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DefaultLoggerManager.java
  
  Index: DefaultLoggerManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DefaultLoggerManager.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DefaultLoggerManager.java	23 Oct 2002 16:33:04 -0000	1.15
  +++ DefaultLoggerManager.java	18 Nov 2002 10:52:53 -0000	1.16
  @@ -63,8 +63,8 @@
   import org.apache.avalon.excalibur.logger.LoggerManager;
   import org.apache.avalon.framework.logger.AvalonFormatter;
   import org.apache.avalon.framework.logger.LogKitLogger;
  -import org.apache.excalibur.merlin.model.CategoriesDescriptor;
  -import org.apache.excalibur.merlin.model.Category;
  +import org.apache.excalibur.meta.model.LoggingDirective;
  +import org.apache.excalibur.meta.model.Category;
   import org.apache.excalibur.merlin.model.FileTargetProvider;
   import org.apache.excalibur.merlin.model.LoggingDescriptor;
   import org.apache.excalibur.merlin.model.TargetDescriptor;
  @@ -220,7 +220,7 @@
        * Add a set of category entries using the supplied categories descriptor.
        * @param descriptor a set of category descriptors to be added under the path
        */
  -    public void addCategories( CategoriesDescriptor descriptor )
  +    public void addCategories( LoggingDirective descriptor )
       {
           addCategories( "", descriptor );
       }
  @@ -232,7 +232,7 @@
        * @param descriptor a set of category descriptors to be added under
        *   the base path
        */
  -    public void addCategories( String path, CategoriesDescriptor descriptor )
  +    public void addCategories( String path, LoggingDirective descriptor )
       {
           addCategory( path, descriptor.getPriority(), descriptor.getTarget() );
           Category[] categories = descriptor.getCategories();
  
  
  
  1.8       +8 -7      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DefaultSelector.java
  
  Index: DefaultSelector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DefaultSelector.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultSelector.java	23 Oct 2002 16:33:04 -0000	1.7
  +++ DefaultSelector.java	18 Nov 2002 10:52:53 -0000	1.8
  @@ -56,7 +56,8 @@
   package org.apache.excalibur.merlin.assembly;
   
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.excalibur.merlin.model.Profile;
  +import org.apache.excalibur.meta.model.Profile;
  +import org.apache.excalibur.meta.model.Mode;
   
   /**
    * Default selector class.
  @@ -81,14 +82,14 @@
               return null;
           }
   
  -        Profile profile = select( profiles, Profile.EXPLICIT );
  +        Profile profile = select( profiles, Mode.EXPLICIT );
           if( profile == null )
           {
  -            profile = select( profiles, Profile.PACKAGED );
  +            profile = select( profiles, Mode.PACKAGED );
           }
           if( profile == null )
           {
  -            profile = select( profiles, Profile.IMPLICIT );
  +            profile = select( profiles, Mode.IMPLICIT );
           }
           if( profile != null )
           {
  @@ -97,11 +98,11 @@
           return profiles[ 0 ];
       }
   
  -    private Profile select( Profile[] profiles, int mode )
  +    private Profile select( Profile[] profiles, Mode mode )
       {
           for( int i = 0; i < profiles.length; i++ )
           {
  -            if( profiles[ i ].getMode() == mode )
  +            if( profiles[ i ].getMode().equals( mode ))
               {
                   return profiles[ i ];
               }
  
  
  
  1.7       +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/Selector.java
  
  Index: Selector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/Selector.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Selector.java	23 Oct 2002 16:33:04 -0000	1.6
  +++ Selector.java	18 Nov 2002 10:52:53 -0000	1.7
  @@ -55,7 +55,7 @@
   
   package org.apache.excalibur.merlin.assembly;
   
  -import org.apache.excalibur.merlin.model.Profile;
  +import org.apache.excalibur.meta.model.Profile;
   
   /**
    * Interface implemented by a service selection implementation mechanism.  Classes
  
  
  
  1.13      +8 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ContainerFactory.java
  
  Index: ContainerFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ContainerFactory.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ContainerFactory.java	23 Oct 2002 16:33:05 -0000	1.12
  +++ ContainerFactory.java	18 Nov 2002 10:52:53 -0000	1.13
  @@ -60,6 +60,7 @@
   import org.apache.excalibur.merlin.assembly.ContainerManager;
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.Resource;
  +import org.apache.excalibur.merlin.model.ContainerDescriptor;
   import org.apache.excalibur.merlin.resource.LifestyleHandler;
   import org.apache.excalibur.merlin.resource.ResourceFactory;
   
  @@ -79,6 +80,7 @@
        * @param handler the lifestyle handler
        * @return the resource instance
        * @exception NullPointerException if any of the supplied arguments are null
  +     * @exception IllegalArgumementException if any of the supplied profile is not a container desciptor
        */
       public Resource createResource(
           ContainerManager manager,
  @@ -102,8 +104,13 @@
           {
               throw new NullPointerException( "handler" );
           }
  +        if( !( profile instanceof ContainerDescriptor ) )
  +        {
  +            throw new IllegalArgumentException( "profile is not a container descriptor: " + profile );
  +        }
   
  -        ContainerResource resource = new ContainerResource( manager, profile, context, handler );
  +        ContainerResource resource = 
  +          new ContainerResource( manager, (ContainerDescriptor) profile, context, handler );
           resource.enableLogging( getLogger() );
           return resource;
       }
  
  
  
  1.8       +13 -5     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ContainerHelper.java
  
  Index: ContainerHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ContainerHelper.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ContainerHelper.java	23 Oct 2002 16:33:05 -0000	1.7
  +++ ContainerHelper.java	18 Nov 2002 10:52:53 -0000	1.8
  @@ -91,6 +91,9 @@
       private static final Resources REZ =
           ResourceManager.getPackageResources( ContainerHelper.class );
   
  +    private static final Class DESCRIPTOR_CLASS = 
  +      org.apache.excalibur.merlin.model.ContainerDescriptor.class;
  +
       //=======================================================================
       // state
       //=======================================================================
  @@ -99,7 +102,7 @@
        * Utility class that provides support for marshalling an XML configuration
        * into meta-data and meta-info instances.
        */
  -    private XMLContainerCreator m_creator = new XMLContainerCreator();
  +    private XMLContainerCreator m_creator;
   
       /**
        * Constructor supplied reference to the type manager.
  @@ -130,10 +133,12 @@
        *
        * @param manager the context type manager
        * @param context the service management context
  +     * @exception if an instantion error occurs
        */
       public ContainerHelper(
           ContainerManager manager,
           Registry context )
  +        throws Exception
       {
           this( manager, null, context );
       }
  @@ -146,12 +151,13 @@
        * @param lifestyles the lifestyle manager
        * @param context the parent service management context
        * @exception NullPointerException if the manager arguments is null
  +     * @exception if an instantion error occurs
        */
       public ContainerHelper(
           ContainerManager manager,
           LifestyleManager lifestyles,
           Registry context )
  -        throws NullPointerException
  +        throws Exception
       {
           if( manager == null )
           {
  @@ -161,6 +167,8 @@
           m_manager = manager;
           m_lifestyles = lifestyles;
           m_registry = context;
  +
  +        m_creator = new XMLContainerCreator( DESCRIPTOR_CLASS );
       }
   
       /**
  @@ -189,7 +197,7 @@
               Type type = m_manager.getType( classname );
   
               ContainerDescriptor descriptor =
  -                m_creator.createContainerDescriptor( type, config );
  +                (ContainerDescriptor) m_creator.createContainerDescriptor( type, config );
   
               //
               // create the container manager
  @@ -216,7 +224,7 @@
                   try
                   {
                       final Type t = manager.getType( c );
  -                    final Profile profile = m_creator.createProfile( t, component );
  +                    final Profile profile = (Profile) m_creator.createProfile( t, component );
                       descriptor.addComponent( profile );
                       manager.addProfile( profile );
                   }
  
  
  
  1.10      +13 -5     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ContainerResource.java
  
  Index: ContainerResource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ContainerResource.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ContainerResource.java	24 Oct 2002 04:12:44 -0000	1.9
  +++ ContainerResource.java	18 Nov 2002 10:52:53 -0000	1.10
  @@ -58,10 +58,12 @@
   import java.util.ArrayList;
   import java.util.LinkedList;
   import java.util.List;
  +import java.util.Iterator;
   import org.apache.avalon.framework.activity.Startable;
   import org.apache.avalon.framework.context.Context;
   import org.apache.excalibur.merlin.assembly.ContainerManager;
   import org.apache.excalibur.merlin.model.Profile;
  +import org.apache.excalibur.merlin.model.ContainerDescriptor;
   import org.apache.excalibur.merlin.resource.DefaultResource;
   import org.apache.excalibur.merlin.resource.LifestyleHandler;
   
  @@ -136,7 +138,7 @@
        * @param handler the lifestyle handler
        */
       public ContainerResource( final ContainerManager manager,
  -                              final Profile profile,
  +                              final ContainerDescriptor profile,
                                 final Context context,
                                 final LifestyleHandler handler )
       {
  @@ -214,7 +216,14 @@
               // as a state listener
               //
   
  -            m_container = (Container)super.access();
  +            Object object = super.access();
  +            if( !( object instanceof Container ))
  +            {
  +                final String error = 
  +                  "Object does not implement the Container interface: " + object ;
  +                throw new IllegalStateException( error );
  +            }
  +            m_container = (Container) object;
               m_container.addStateListener( this );
               m_state = StateEvent.INITIALIZED;
   
  @@ -246,7 +255,7 @@
                               || ( m_state == StateEvent.SUSPENDED ) )
                           {
                               m_container.install(
  -                                (Profile[])m_installable.toArray( new Profile[ 0 ] ) );
  +                               (Profile[]) m_installable.toArray( new Profile[ 0 ] ) );
                               m_installable.clear();
                           }
                       }
  @@ -294,7 +303,6 @@
           catch( Throwable e )
           {
               final String error = "Unexpected error during container execution.";
  -            //getLogger().error( ExceptionHelper.packException( error, e ) );
               m_error = new ContainerException( error, e );
           }
       }
  
  
  
  1.48      +14 -19    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.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- DefaultContainer.java	24 Oct 2002 04:12:44 -0000	1.47
  +++ DefaultContainer.java	18 Nov 2002 10:52:53 -0000	1.48
  @@ -72,6 +72,7 @@
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.excalibur.meta.model.Mode;
   import org.apache.excalibur.merlin.ExceptionHelper;
   import org.apache.excalibur.merlin.assembly.AssemblyException;
   import org.apache.excalibur.merlin.assembly.ContainerManager;
  @@ -107,12 +108,6 @@
       //=======================================================================
   
       /**
  -     * Utility class that provides support for marshalling an XML configuration
  -     * into meta-data and meta-info instances.
  -     */
  -    private XMLContainerCreator m_creator = new XMLContainerCreator();
  -
  -    /**
        * The list of initialized embedded containers wrapped in Container instances.
        */
       private Map m_containers = new Hashtable();
  @@ -211,11 +206,16 @@
           //
   
           Thread.currentThread().setContextClassLoader( m_manager );
  -        getLogger().debug( "container '" + m_descriptor.getName()
  -                           + "' executing in thread: '" + Thread.currentThread().getName()
  -                           + "' with context type manager: '" + Thread.currentThread().getContextClassLoader()
  -                           + "'." );
  -
  +        if( getLogger().isDebugEnabled() )
  +        {
  +            getLogger().debug( 
  +              "container '" + m_descriptor.getName()
  +              + "' executing in thread: '" 
  +              + Thread.currentThread().getName()
  +              + "' with context type manager: '" 
  +              + Thread.currentThread().getContextClassLoader()
  +              + "'." );
  +        }
       }
   
       //=======================================================================
  @@ -223,12 +223,7 @@
       //=======================================================================
   
       /**
  -     * Provision of a configuration to the container that is used to establish
  -     * the EXPLICIT components to be included and defintion of subcontainers.
  -     * NOTE: The configuration of the actual container is not supplied here.
  -     * Instead, the implementation may access the configuration supplied under the
  -     * {@link ContainerDescriptor} instance supplied during the contextualization
  -     * phase.
  +     * Configuration of the container.
        *
        * @param config the container configuration
        * @exception ConfigurationException not throw locally but provided for
  @@ -258,7 +253,7 @@
           //
   
           getLogger().debug( "assembly" );
  -        Profile[] profiles = m_descriptor.getComponents( Profile.EXPLICIT, true );
  +        Profile[] profiles = m_descriptor.getComponents( Mode.EXPLICIT, true );
           try
           {
               getLogger().debug( "profile assembly (" + profiles.length + ")" );
  
  
  
  1.59      +8 -7      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.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- DefaultKernel.java	24 Oct 2002 04:12:44 -0000	1.58
  +++ DefaultKernel.java	18 Nov 2002 10:52:53 -0000	1.59
  @@ -82,14 +82,14 @@
   import org.apache.excalibur.merlin.container.Container;
   import org.apache.excalibur.merlin.container.ContainerHelper;
   import org.apache.excalibur.merlin.container.ContainerResource;
  -import org.apache.excalibur.merlin.model.CategoriesDescriptor;
  +import org.apache.excalibur.meta.model.LoggingDirective;
   import org.apache.excalibur.merlin.model.ClasspathDescriptor;
   import org.apache.excalibur.merlin.model.LibraryDescriptor;
   import org.apache.excalibur.merlin.model.LoggingDescriptor;
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.builder.XMLContainerCreator;
   import org.apache.excalibur.merlin.model.verifier.AssemblyVerifier;
  -import org.apache.excalibur.merlin.model.verifier.MetaDataVerifier;
  +import org.apache.excalibur.meta.model.verifier.ProfileVerifier;
   import org.apache.excalibur.merlin.resource.DefaultLifestyleManager;
   import org.apache.excalibur.merlin.resource.LifestyleManager;
   import org.apache.excalibur.merlin.service.DefaultRegistry;
  @@ -181,7 +181,7 @@
   
       private Context m_context;
   
  -    private XMLContainerCreator m_creator = new XMLContainerCreator();
  +    private XMLContainerCreator m_creator ;
   
       private TPCThreadManager m_threadManager;
       private CommandManager m_commandManager;
  @@ -329,6 +329,7 @@
        */
       public void initialize() throws Exception
       {
  +        m_creator = new XMLContainerCreator();
           ClassLoader classloader = Thread.currentThread().getContextClassLoader();
           final Configuration config = m_config.getChild( "container" );
           String name = config.getAttribute( "name" );
  @@ -353,8 +354,8 @@
               //
   
               Configuration categoriesConfig = config.getChild( "categories" );
  -            CategoriesDescriptor categories =
  -                m_creator.createCategoriesDescriptor( m_base, categoriesConfig );
  +            LoggingDirective categories =
  +                m_creator.createLoggingDirective( m_base, categoriesConfig );
               getLoggingManager().addCategories( m_base, categories );
               m_logger = getLoggingManager().getLoggerForCategory( m_base );
               m_localLogger = m_logger.getChildLogger( "kernel" );
  @@ -677,7 +678,7 @@
           getLogger().debug( "verify" );
   
           Profile[] profiles = m_manager.getStartupGraph( false );
  -        MetaDataVerifier mdv = new MetaDataVerifier();
  +        ProfileVerifier mdv = new ProfileVerifier();
           for( int i = 0; i < profiles.length; i++ )
           {
               try
  
  
  
  1.19      +16 -18    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/ContainerDescriptor.java
  
  Index: ContainerDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/ContainerDescriptor.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ContainerDescriptor.java	23 Oct 2002 16:33:06 -0000	1.18
  +++ ContainerDescriptor.java	18 Nov 2002 10:52:53 -0000	1.19
  @@ -59,6 +59,9 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.excalibur.meta.info.Type;
  +import org.apache.excalibur.meta.model.ContextDirective;
  +import org.apache.excalibur.meta.model.Mode;
  +import org.apache.excalibur.meta.model.LoggingDirective;
   
   /**
    * <p>A container descriptor is a description of the crieria supporting the
  @@ -125,7 +128,7 @@
    *    &lt;/container&gt;
    * </pre>
    *
  - * @see Profile
  + * @see org.apache.excalibur.merlin.model.Profile
    * @see ClasspathDescriptor
    *
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
  @@ -181,23 +184,18 @@
        * @param context the context instance to use during type instantiation
        * @param categories the logging categories descriptor
        * @param type the type of component that this profile qualifies
  -     * @param enabled the enabled state of the component profile
  -     * @param activation TRUE if activation on startup, FALSE to activate on request
        * @param mode the creation mode (either IMPLICIT, PACKAGED, or EXPLICIT)
        */
       public ContainerDescriptor( final String name,
                                   final Parameters parameters,
                                   final Configuration configuration,
                                   final ContextDirective context,
  -                                final CategoriesDescriptor categories,
  +                                final LoggingDirective categories,
                                   final Type type,
  -                                final boolean enabled,
  -                                final boolean activation,
  -                                final int mode )
  +                                final Mode mode )
       {
           super(
  -            name, parameters, configuration, context, categories, type, enabled,
  -            activation, mode
  +            name, parameters, configuration, context, categories, type, mode
           );
       }
   
  @@ -253,12 +251,12 @@
        * Return the set of component descriptors contained within this container matching
        * the supplied mode.
        *
  -     * @param mode one of enumerated value {@link Profile#IMPLICIT}, {@link Profile#PACKAGED},
  -     *    or {@link Profile#EXPLICIT}
  +     * @param mode one of enumerated value {@link Mode#IMPLICIT}, {@link Mode#PACKAGED},
  +     *    or {@link Mode#EXPLICIT}
        * @param enabled TRUE to select enabled components, FALSE returns disabled components
        * @return the profiles matching the supplied creation mode
        */
  -    public Profile[] getComponents( int mode, boolean enabled )
  +    public Profile[] getComponents( Mode mode, boolean enabled )
       {
           ArrayList list = new ArrayList();
           Profile[] components = getComponents( enabled );
  @@ -269,11 +267,11 @@
        * Return the set of component descriptors contained within this container matching
        * the supplied mode.
        *
  -     * @param mode one of enumerated value {@link Profile#IMPLICIT}, {@link Profile#PACKAGED},
  -     *    or {@link Profile#EXPLICIT},
  +     * @param mode one of enumerated value {@link Mode#IMPLICIT}, {@link Mode#PACKAGED},
  +     *    or {@link Mode#EXPLICIT},
        * @return the descriptors matching the supplied creation mode
        */
  -    public Profile[] getComponents( int mode )
  +    public Profile[] getComponents( Mode mode )
       {
           return selectComponentsByMode( getComponents(), mode );
       }
  @@ -285,13 +283,13 @@
        * @param the subset of the supplied components with a creation mode matching
        *   the supplied mode value
        */
  -    private Profile[] selectComponentsByMode( Profile[] components, int mode )
  +    private Profile[] selectComponentsByMode( Profile[] components, Mode mode )
       {
           ArrayList list = new ArrayList();
           for( int i = 0; i < components.length; i++ )
           {
               Profile component = components[ i ];
  -            if( component.getMode() == mode )
  +            if( component.getMode().equals( mode ) )
               {
                   list.add( component );
               }
  
  
  
  1.14      +4 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/LoggingDescriptor.java
  
  Index: LoggingDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/LoggingDescriptor.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- LoggingDescriptor.java	23 Oct 2002 16:33:06 -0000	1.13
  +++ LoggingDescriptor.java	18 Nov 2002 10:52:53 -0000	1.14
  @@ -55,6 +55,9 @@
   
   package org.apache.excalibur.merlin.model;
   
  +import org.apache.excalibur.meta.model.Category;
  +
  +
   /**
    * Description of a top level logging environment.
    *
  
  
  
  1.32      +43 -421   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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- Profile.java	24 Oct 2002 04:12:44 -0000	1.31
  +++ Profile.java	18 Nov 2002 10:52:54 -0000	1.32
  @@ -67,108 +67,20 @@
   import org.apache.excalibur.meta.ConfigurationBuilder;
   import org.apache.excalibur.meta.info.StageDescriptor;
   import org.apache.excalibur.meta.info.Type;
  +import org.apache.excalibur.meta.model.ContextDirective;
  +import org.apache.excalibur.meta.model.LoggingDirective;
  +import org.apache.excalibur.meta.model.Mode;
   import org.xml.sax.InputSource;
   
   /**
  - * Definition of the criteria for an explicit component profile.  A profile, when
  - * included within the scope of a container declaration will be instantiated in
  - * the model as an EXPLICIT component profile resulting in the initiation of
  - * dependency resolution relative to the component as the target deployment
  - * objective.  Multiple supplementary profiles may be packaged in a .xprofiles
  - * resources and will be assigned to the container automatically.  In the absence
  - * of explicit or packaged profile directives, an implicit profile will be created
  - * for any component types declared under a jar manifest.
  - *
  - * <p><b>XML</b></p>
  - * <p>A component element declares the profile to be applied during the instantiation
  - * of a component type.  It includes a name and class declaration, logging directives
  - * (resolved relative to the component's container), context creation criteria,
  - * together with configuration or parameters information.</p>
  - *
  - * <pre>
  - <font color="gray"><i>&lt;!--
  - Declaration of the services hosted by this container.  Service container here
  - will be managed relative to other provider components at the same level and
  - may be serviced by components declared in parent container.
  - --&gt;</i></font>
  -
  - &lt;component name="<font color="darkred">complex</font>" class="<font color="darkred">org.apache.excalibur.playground.ComplexComponent</font>" activation="<font color="darkred">startup</font>"&gt;
  -
  - <font color="gray"><i>&lt;!--
  - Priority and target assignments for component specific logging categrories.
  - --&gt;</i></font>
  -
  - &lt;categories priority="<font color="darkred">DEBUG</font>"&gt;
  - &lt;category name="<font color="darkred">init</font>" priority="<font color="darkred">DEBUG</font>" /&gt;
  - &lt;/categories&gt;
  -
  - <font color="gray"><i>&lt;!--
  - Include the following context value in the context supplied a component using this
  - profile.  Context entries are normally only required in the case where the component
  - type declares a required context type and entry values. Generally speaking, a component
  - will normally qualify it's instantiation criteria through a configuration declaration.
  - Any context values defined at this level will override context values supplied by the
  - container.
  - --&gt;</i></font>
  -
  - &lt;context&gt;
  - &lt;entry name="<font color="darkred">location</font>" value="<font color="darkred">Paris</font>"/&gt;
  - &lt;/context&gt;
  -
  - <font color="gray"><i>&lt;!--
  - Apply the following configuration when instantiating the component.  This configuration
  - will be applied as the primary configuration in a cascading configuration chain.  A
  - type may declare a default configuration under a "classname".xconfig file that will be
  - used to dereference any configuration requests not resolvable by the configuration
  - supplied here.
  - --&gt;</i></font>
  -
  - &lt;configuration&gt;
  - &lt;message value="<font color="darkred">Hello</font>"/&gt;
  - &lt;/configuration&gt;
  -
  - <font color="gray"><i>&lt;!--
  - The parameterization criteria from this instance of the component type.
  - --&gt;</i></font>
  -
  - &lt;parameters/&gt;
  -
  - &lt;/component&gt;
  - * </pre>
  - *
  - *
  - * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
    * @version $Revision$ $Date$
    */
  -public class Profile implements Serializable
  +public class Profile extends org.apache.excalibur.meta.model.Profile
   {
  -
  -    /**
  -     * Constant indicating that the profile was implicitly created.
  -     */
  -    public static final int IMPLICIT = 0;
  -
  -    /**
  -     * Constant indicating that the profile was created based on a profile packaged with the type.
  -     */
  -    public static final int PACKAGED = 1;
  -
  -    /**
  -     * Constant indicating that the profile was explicitly declared under an assembly directive.
  -     */
  -    public static final int EXPLICIT = 2;
  -
  -    /**
  -     * The name of the component profile. This is an
  -     * abstract name used during assembly.
  -     */
  -    private final String m_name;
  -
  -    /**
  -     * The assigned logging categories.
  -     */
  -    private final CategoriesDescriptor m_categories;
  +     public static final int IMPLICIT = Mode.IMPLICIT.getValue();
  +     public static final int PACKAGED = Mode.PACKAGED.getValue();
  +     public static final int EXPLICIT = Mode.EXPLICIT.getValue();
   
       /**
        * The dependencies keyed by role name.
  @@ -186,36 +98,6 @@
       private final Hashtable m_extensions = new Hashtable();
   
       /**
  -     * The info object for component type.
  -     */
  -    private final Type m_type;
  -
  -    /**
  -     * The parameters for component (if any).
  -     */
  -    private final Parameters m_parameters;
  -
  -    /**
  -     * The configuration for component (if any).
  -     */
  -    private final Configuration m_configuration;
  -
  -    /**
  -     * The derived configuration
  -     */
  -    private Configuration m_config;
  -
  -    /**
  -     * The configuration for component (if any).
  -     */
  -    private final ContextDirective m_context;
  -
  -    /**
  -     * The creation mode.
  -     */
  -    private final int m_mode;
  -
  -    /**
        * The enabled status of the profile.  Normally a profile is enabled however, a
        * failure to assemble will result in the disabling of the profile.
        */
  @@ -224,11 +106,10 @@
       /**
        * The activation policy - TRUE if activation on startup, FALSE to activate on request.
        */
  -    private final boolean m_activation;
  +    private boolean m_activation = true;
   
       /**
  -     * Create an Profile instance, enabled, lazy activation and explicit
  -     * status.
  +     * Create an explicit Profile instance.
        *
        * @param name the abstract name of the profile
        * @param type the type of component that this profile qualifies
  @@ -236,9 +117,9 @@
        */
       public Profile( final String name,
                       final Type type,
  -                    final CategoriesDescriptor categories )
  +                    final LoggingDirective categories )
       {
  -        this( name, null, null, null, categories, type, true, false, EXPLICIT );
  +        super( name, type, categories );
       }
   
       /**
  @@ -249,24 +130,20 @@
        * @param context the context instance to use during type instantiation
        * @param categories the logging categories descriptor
        * @param type the type of component that this profile qualifies
  -     * @param enabled the enabled state of the component profile
  -     * @param activation TRUE if activation on startup, FALSE to activate on request
        * @param mode the creation mode (either IMPLICIT, PACKAGED, or EXPLICIT)
        */
       public Profile( final String name,
                       final Configuration configuration,
                       final ContextDirective context,
  -                    final CategoriesDescriptor categories,
  +                    final LoggingDirective categories,
                       final Type type,
  -                    final boolean enabled,
  -                    final boolean activation,
  -                    final int mode )
  +                    final Mode mode )
       {
  -        this( name, null, configuration, context, categories, type, enabled, activation, mode );
  +        super( name, configuration, context, categories, type, mode );
       }
   
       /**
  -     * Create a Profile instance without parameters.
  +     * Create an explicit Profile instance without parameters.
        *
        * @param name the abstract name of profile
        * @param activation the profile activation policy
  @@ -274,16 +151,7 @@
        */
       public Profile( final String name, boolean activation, final Profile template )
       {
  -        this(
  -            name,
  -            template.getParameters(),
  -            template.getConfiguration(),
  -            template.getContext(),
  -            template.getCategories(),
  -            template.getType(),
  -            template.isEnabled(),
  -            activation,
  -            EXPLICIT );
  +        super( name, activation, template );
       }
   
       /**
  @@ -295,105 +163,62 @@
        * @param context the context instance to use during type instantiation
        * @param categories the logging categories descriptor
        * @param type the type of component that this profile qualifies
  -     * @param enabled the enabled state of the component profile
  -     * @param activation TRUE if activation on startup, FALSE to activate on request
        * @param mode the creation mode (either IMPLICIT, PACKAGED, or EXPLICIT)
        */
       public Profile( final String name,
                       final Parameters parameters,
                       final Configuration configuration,
                       final ContextDirective context,
  -                    final CategoriesDescriptor categories,
  +                    final LoggingDirective categories,
                       final Type type,
  -                    final boolean enabled,
  -                    final boolean activation,
  -                    final int mode )
  -    {
  -        if( null == type )
  -        {
  -            throw new NullPointerException( "type" );
  -        }
  -
  -        if( null == name )
  -        {
  -            m_name = type.getInfo().getName() + "-" + System.identityHashCode( this );
  -        }
  -        else
  -        {
  -            if( mode != EXPLICIT )
  -            {
  -                m_name = name + "-" + System.identityHashCode( this );
  -            }
  -            else
  -            {
  -                m_name = name;
  -            }
  -        }
  -
  -        if( null == categories )
  -        {
  -            throw new NullPointerException( "categories" );
  -        }
  -
  -        m_parameters = parameters;
  -        m_configuration = configuration;
  -        m_categories = categories;
  -        m_type = type;
  -        m_context = context;
  -        m_enabled = enabled;
  -        m_activation = activation;
  -        m_mode = mode;
  -    }
  -
  -    /**
  -     * Test is this profile is enabled.  A profile is enabled unless explicitly disabled by an
  -     * assembly directive, or implicity disabled as a result of an assembly failure.
  -     *
  -     * @return TRUE if the profile is enabled.
  -     * @see #setEnabled( boolean )
  -     */
  -    public boolean isEnabled()
  +                    final Mode mode )
       {
  -        return m_enabled;
  +        super( name, parameters, configuration, context, categories, type, mode );
       }
   
       /**
  -     * Set the enabled status of the profile to the supplied value.
  -     * @param value the enabled status - TRUE or FALSE
  +     * Set the activation policy for the component.  If TRUE, activation
  +     * will occur at startup.  If false, activation will be deferred to
  +     * the first lookup invocation if any (i.e. lazy activation).
  +     *
  +     * @return the activation policy
        */
  -    public void setEnabled( boolean value )
  +    public void setActivationPolicy( boolean policy )
       {
  -        m_enabled = value;
  +        m_activation = policy;
       }
   
       /**
  -     * Return the name of component metadata instance.
  +     * Return the activation policy for the component.  If TRUE, activation
  +     * will occur at startup.  If false, activation will be deferred to
  +     * the first lookup invocation if any (i.e. lazy activation).
        *
  -     * @return the name of the component.
  +     * @return the activation policy
        */
  -    public String getName()
  +    public boolean getActivationPolicy()
       {
  -        return m_name;
  +        return m_activation;
       }
   
       /**
  -     * Return the logging categories for the profile.
  +     * Test is this profile is enabled.  A profile is enabled unless explicitly disabled by an
  +     * assembly directive, or implicity disabled as a result of an assembly failure.
        *
  -     * @return the logger
  +     * @return TRUE if the profile is enabled.
  +     * @see #setEnabled( boolean )
        */
  -    public CategoriesDescriptor getCategories()
  +    public boolean isEnabled()
       {
  -        return m_categories;
  +        return m_enabled;
       }
   
       /**
  -     * Return the type info for component.
  -     *
  -     * @return the info for component type.
  +     * Set the enabled status of the profile to the supplied value.
  +     * @param value the enabled status - TRUE or FALSE
        */
  -    public Type getType()
  +    public void setEnabled( boolean value )
       {
  -        return m_type;
  +        m_enabled = value;
       }
   
       /**
  @@ -407,111 +232,6 @@
       }
   
       /**
  -     * Return the context directive for the profile.
  -     *
  -     * @return the ContextDirective for the profile.
  -     */
  -    public ContextDirective getContext()
  -    {
  -        return m_context;
  -    }
  -
  -    /**
  -     * Return the Parameters for the profile.
  -     *
  -     * @return the Parameters for Component (if any).
  -     */
  -    public Parameters getParameters()
  -    {
  -        return m_parameters;
  -    }
  -
  -    /**
  -     * Return the base Configuration for the profile.
  -     *
  -     * @return the base Configuration for profile.
  -     */
  -    public Configuration getConfiguration()
  -    {
  -        return m_configuration;
  -    }
  -
  -    /**
  -     * Return the derived Configuration for the profile as a
  -     * {@link CascadingConfiguration}. The primary configuration
  -     * is either the base configuration of a configuration referenced
  -     * by the attribute <code>src</code> and the default configuration
  -     * is resolved from the &lt;classname&gt;.xconfig resourse.
  -     *
  -     * @param classloader the classloader to use
  -     * @return the Configuration for profile.
  -     * @exception Exception if an error occurs while resolving the configuration
  -     */
  -    public Configuration getConfiguration( ClassLoader classloader ) throws Exception
  -    {
  -        if( m_config != null )
  -        {
  -            return m_config;
  -        }
  -
  -        final Class type = classloader.loadClass(
  -            getType().getInfo().getImplementationKey() );
  -        if( !Configurable.class.isAssignableFrom( type ) )
  -        {
  -            return null;
  -        }
  -
  -        final Configuration defaults = getType().getConfiguration( 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 from 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.
        *
        * @param role the dependency role name
  @@ -523,15 +243,6 @@
       }
   
       /**
  -     * Returns the creation mode for this profile.
  -     * @return a value of EXPLICIT, PACKAGED or IMPLICIT
  -     */
  -    public int getMode()
  -    {
  -        return m_mode;
  -    }
  -
  -    /**
        * Add an association for a service dependency.
        * @param role the role against which the supplied resource is to be associated
        * @param resource the resource that will fulfill the provider dependency
  @@ -577,93 +288,4 @@
           return (Profile)m_extensions.get( stage );
       }
   
  -    /**
  -     * Return the activation policy for the component.  If TRUE, activation
  -     * will occur at startup.  If false, activation will be deferred to
  -     * the first lookup invocation if any (i.e. lazy activation).
  -     *
  -     * @return the activation policy
  -     */
  -    public boolean getActivationPolicy()
  -    {
  -        return m_activation;
  -    }
  -
  -    /**
  -     * Returns a string representation of the profile.
  -     * @return a string representation
  -     */
  -    public String toString()
  -    {
  -        return "Profile name: " + getName()
  -            + ", type: " + getType().getInfo().getName()
  -            + ", mode: " + modeToString( getMode() );
  -    }
  -
  -    /**
  -     * Provide a textual report on the profile.
  -     * @return the formatted profile report
  -     */
  -    public String list()
  -    {
  -        StringBuffer buffer = new StringBuffer();
  -        buffer.append( "PROFILE REPORT\n" );
  -        buffer.append( "\n  name: " + getName() );
  -        buffer.append( "\n  base: " + getType().getInfo().getName() );
  -        buffer.append( "\n  key: " + getType().getInfo().getImplementationKey() );
  -        buffer.append( "\n  context: " + getContext() );
  -        buffer.append( "\n  configuration:" );
  -        if( getConfiguration() != null )
  -        {
  -            buffer.append( ConfigurationUtil.list( getConfiguration() ) );
  -        }
  -        else
  -        {
  -            buffer.append( " null" );
  -        }
  -        buffer.append( "\n  parameters: " + getParameters() );
  -        buffer.append( "\n  dependecies" );
  -
  -        Association[] dependencies = getAssociations();
  -        if( dependencies.length == 0 )
  -        {
  -            buffer.append( " (none)\n\n" );
  -            return buffer.toString();
  -        }
  -
  -        for( int i = 0; i < dependencies.length; i++ )
  -        {
  -            buffer.append( "\n  dependency " + i );
  -            buffer.append( "\n    role: " + dependencies[ i ].getRole() );
  -            buffer.append( "\n    provider: " + dependencies[ i ].getProvider() );
  -        }
  -
  -        buffer.append( "\n\n" );
  -        return buffer.toString();
  -    }
  -
  -   /**
  -    * Returns a string representation of a mode value.
  -    * @param mode the mode value
  -    * @return the string representation
  -    */
  -    public static String modeToString( int mode )
  -    {
  -        if( mode == IMPLICIT )
  -        {
  -            return "IMPLICIT";
  -        }
  -        else if( mode == PACKAGED )
  -        {
  -            return "PACKAGED";
  -        }
  -        else if( mode == EXPLICIT )
  -        {
  -            return "EXPLICIT";
  -        }
  -        else
  -        {
  -            return "?";
  -        }
  -    }
   }
  
  
  
  1.12      +2 -1      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Resource.java	24 Oct 2002 04:12:44 -0000	1.11
  +++ Resource.java	18 Nov 2002 10:52:54 -0000	1.12
  @@ -59,6 +59,7 @@
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.excalibur.meta.info.ReferenceDescriptor;
   import org.apache.excalibur.meta.info.ServiceDescriptor;
  +import org.apache.excalibur.merlin.model.Profile;
   
   /**
    * Interface implemented by object capable of supply a resources indepedently
  
  
  
  1.10      +26 -8     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ContainerBuilder.java
  
  Index: ContainerBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ContainerBuilder.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ContainerBuilder.java	23 Oct 2002 16:33:07 -0000	1.9
  +++ ContainerBuilder.java	18 Nov 2002 10:52:54 -0000	1.10
  @@ -59,6 +59,7 @@
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.excalibur.merlin.model.ContainerDescriptor;
  +import org.apache.excalibur.merlin.model.ModelRuntimeException;
   import org.apache.excalibur.meta.info.Type;
   
   /**
  @@ -73,7 +74,22 @@
       private static final Resources REZ =
           ResourceManager.getPackageResources( ContainerBuilder.class );
   
  -    private final ContainerCreator m_xmlContainerCreator = createXMLContainerCreator();
  +    private final ContainerCreator m_xmlContainerCreator;
  +
  +    public ContainerBuilder() throws Exception
  +    {
  +        this( ContainerDescriptor.class );
  +    }
  +
  +   /**
  +    * Creation of a container builder that uses the supplied base class for
  +    * new container profile creation.
  +    * @param base the container descriptor base class
  +    */
  +    public ContainerBuilder( Class base ) throws Exception
  +    {
  +        m_xmlContainerCreator = createXMLContainerCreator( base );
  +    }
   
       /**
        * Build ContainerDescriptor from the XML descriptor format.
  @@ -119,20 +135,22 @@
       /**
        * Utility to get XMLContainerCreator if XML files are on
        * ClassPath.
  -     *
  -     * @return the XML {@link ContainerCreator}
  +     * @param basse the base class for the container descriptor
  +     * @return the XML container descriptor creator {@link ContainerCreator}
        */
  -    private static ContainerCreator createXMLContainerCreator()
  +    private static ContainerCreator createXMLContainerCreator( Class base )
       {
           ContainerCreator xmlContainerCreator = null;
           try
           {
  -            xmlContainerCreator = new XMLContainerCreator();
  +            xmlContainerCreator = new XMLContainerCreator( base );
           }
           catch( final Exception e )
           {
  -            //Ignore it if ClassNot found due to no
  -            //XML Classes on classpath
  +            final String error = 
  +              "Unexpected error while attempting to create the XML Container Creator." 
  +              + " Base: " + base.getName();
  +            throw new ModelRuntimeException( error, e ); 
           }
           return xmlContainerCreator;
       }
  
  
  
  1.18      +54 -29    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLContainerCreator.java
  
  Index: XMLContainerCreator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLContainerCreator.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- XMLContainerCreator.java	23 Oct 2002 16:33:07 -0000	1.17
  +++ XMLContainerCreator.java	18 Nov 2002 10:52:54 -0000	1.18
  @@ -57,29 +57,34 @@
   
   import java.io.InputStream;
   import java.util.ArrayList;
  +import java.lang.reflect.Constructor;
  +import java.lang.reflect.Array;
  +
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   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.excalibur.merlin.model.CategoriesDescriptor;
  -import org.apache.excalibur.merlin.model.Category;
  +import org.apache.excalibur.meta.ConfigurationBuilder;
  +import org.apache.excalibur.meta.info.Type;
  +import org.apache.excalibur.meta.model.LoggingDirective;
  +import org.apache.excalibur.meta.model.Category;
  +import org.apache.excalibur.meta.model.ContextDirective;
  +import org.apache.excalibur.meta.model.Entry;
  +import org.apache.excalibur.meta.model.Import;
  +import org.apache.excalibur.meta.model.Mode;
  +import org.apache.excalibur.merlin.model.Profile;
  +import org.apache.excalibur.meta.model.builder.XMLProfileCreator;
   import org.apache.excalibur.merlin.model.ClasspathDescriptor;
   import org.apache.excalibur.merlin.model.ContainerDescriptor;
  -import org.apache.excalibur.merlin.model.ContextDirective;
  -import org.apache.excalibur.merlin.model.Entry;
   import org.apache.excalibur.merlin.model.FileTargetProvider;
   import org.apache.excalibur.merlin.model.FilesetDescriptor;
  -import org.apache.excalibur.merlin.model.Import;
   import org.apache.excalibur.merlin.model.IncludeDescriptor;
   import org.apache.excalibur.merlin.model.LibraryDescriptor;
   import org.apache.excalibur.merlin.model.LoggingDescriptor;
  -import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.TargetDescriptor;
   import org.apache.excalibur.merlin.model.TargetProvider;
  -import org.apache.excalibur.meta.ConfigurationBuilder;
  -import org.apache.excalibur.meta.info.Type;
   import org.xml.sax.InputSource;
   
   /**
  @@ -96,6 +101,24 @@
       private static final Resources REZ =
           ResourceManager.getPackageResources( XMLContainerCreator.class );
   
  +    private Class m_clazz;
  +
  +    public XMLContainerCreator() throws Exception
  +    {
  +        this( ContainerDescriptor.class );
  +    }
  +
  +   /**
  +    * Creation of a container builder that uses the supplied base class for
  +    * new container profile creation.
  +    * @param base the container descriptor base class
  +    */
  +    public XMLContainerCreator( Class base ) throws Exception
  +    {
  +        super( base );
  +        m_clazz = base;
  +    }
  +
       /**
        * Create an array of packaged {@link ContainerDescriptor} objects for specified
        * container type, loaded from specified {@link InputStream}.  If the
  @@ -139,7 +162,7 @@
           Type type, Configuration config )
           throws Exception
       {
  -        return buildContainerDescriptor( type, config, Profile.EXPLICIT );
  +        return buildContainerDescriptor( type, config, Mode.EXPLICIT );
       }
   
       /**
  @@ -168,10 +191,11 @@
           {
               vector.add(
                   buildContainerDescriptor(
  -                    type, profiles[ i ], Profile.PACKAGED ) );
  +                    type, profiles[ i ], Mode.PACKAGED ) );
           }
  +
           return (ContainerDescriptor[])vector.toArray(
  -            new ContainerDescriptor[ 0 ] );
  +             (Object[]) Array.newInstance( m_clazz, 0 )  );
       }
   
       private ContainerDescriptor createImplicitContainerDescriptor( Type type )
  @@ -182,33 +206,33 @@
               new Import[ 0 ], new Entry[ 0 ] );
           final Configuration defaults =
               new DefaultConfiguration( "default", null );
  -        final CategoriesDescriptor categories =
  -            createDefaultCategoriesDescriptor( type );
  +        final LoggingDirective categories =
  +            createDefaultLoggingDirective( type );
           final ClasspathDescriptor classpath =
               new ClasspathDescriptor();
   
  -        return new ContainerDescriptor(
  -            null, null, defaults, context, categories, type, true, false,
  -            Profile.IMPLICIT
  -        );
  +        return (ContainerDescriptor) getConstructor().newInstance(
  +          new Object[]{
  +            null, null, defaults, context, categories, type, Mode.IMPLICIT } );
       }
   
       private ContainerDescriptor buildContainerDescriptor(
  -        Type type, Configuration profile, int mode )
  +        Type type, Configuration profile, Mode mode )
           throws Exception
       {
  -
           //
           // create the logging categories for this profile
           //
   
           final String name = profile.getAttribute( "name" );
  -        CategoriesDescriptor categories =
  -            createCategoriesDescriptor( name, profile.getChild( "categories" ) );
  -        final boolean enabled =
  -            profile.getAttributeAsBoolean( "enabled", true );
  -        final boolean activation =
  -            getActivationMode( profile );
  +        LoggingDirective categories =
  +            createLoggingDirective( name, profile.getChild( "categories" ) );
  +
  +        //final boolean enabled =
  +        //    profile.getAttributeAsBoolean( "enabled", true );
  +        //final boolean activation =
  +        //    getActivationMode( profile );
  +
           final Parameters params =
               Parameters.fromConfiguration( profile.getChild( "parameters" ) );
           final ContextDirective context =
  @@ -220,9 +244,10 @@
           // create the profile instance
           //
   
  -        return new ContainerDescriptor(
  -            name, params, config, context, categories, type,
  -            enabled, activation, mode );
  +        return (ContainerDescriptor) getConstructor().newInstance(
  +          new Object[]{
  +            name, params, config, context, categories, type, mode } );
  +
       }
   
       /**
  
  
  
  1.10      +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/verifier/AssemblyVerifier.java
  
  Index: AssemblyVerifier.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/verifier/AssemblyVerifier.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AssemblyVerifier.java	23 Oct 2002 16:33:08 -0000	1.9
  +++ AssemblyVerifier.java	18 Nov 2002 10:52:54 -0000	1.10
  @@ -61,11 +61,11 @@
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.excalibur.merlin.model.Association;
  -import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.meta.info.DependencyDescriptor;
   import org.apache.excalibur.meta.info.ReferenceDescriptor;
   import org.apache.excalibur.meta.info.ServiceDescriptor;
   import org.apache.excalibur.meta.info.Type;
  +import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.meta.verifier.VerifyException;
   
   /**
  
  
  
  1.15      +11 -11    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DeploymentHelper.java
  
  Index: DeploymentHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DeploymentHelper.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- DeploymentHelper.java	23 Oct 2002 16:33:08 -0000	1.14
  +++ DeploymentHelper.java	18 Nov 2002 10:52:54 -0000	1.15
  @@ -75,11 +75,11 @@
   import org.apache.excalibur.merlin.assembly.ContainerManager;
   import org.apache.excalibur.merlin.assembly.DefaultLoggerManager;
   import org.apache.excalibur.merlin.assembly.KernelManager;
  -import org.apache.excalibur.merlin.model.CategoriesDescriptor;
  -import org.apache.excalibur.merlin.model.Category;
  -import org.apache.excalibur.merlin.model.ContextDirective;
  -import org.apache.excalibur.merlin.model.Entry;
  -import org.apache.excalibur.merlin.model.Import;
  +import org.apache.excalibur.meta.model.LoggingDirective;
  +import org.apache.excalibur.meta.model.Category;
  +import org.apache.excalibur.meta.model.ContextDirective;
  +import org.apache.excalibur.meta.model.Entry;
  +import org.apache.excalibur.meta.model.Import;
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.meta.info.ContextDescriptor;
   import org.apache.excalibur.meta.info.EntryDescriptor;
  @@ -206,7 +206,7 @@
           //
   
           String root;
  -        CategoriesDescriptor categories = buildLoggingCategories( profile );
  +        LoggingDirective categories = buildLoggingCategories( profile );
           if( m_manager instanceof KernelManager )
           {
               root = m_manager.getPath().replace( '/', '.' ).substring( 1 );
  @@ -222,15 +222,15 @@
       /**
        * Create a categories descriptor that takes into account both type logging
        * category declarations and the profile level logging category definitions
  -     * under a single <code>CategoriesDescriptor</code> instance.
  +     * under a single <code>LoggingDirective</code> instance.
        *
        * @param profile the profile defining the type and profile level category
        *   information
  -     * @return a new fully populated <code>CategoriesDescriptor</code>
  +     * @return a new fully populated <code>LoggingDirective</code>
        */
  -    private CategoriesDescriptor buildLoggingCategories( Profile profile )
  +    private LoggingDirective buildLoggingCategories( Profile profile )
       {
  -        CategoriesDescriptor categories = profile.getCategories();
  +        LoggingDirective categories = profile.getCategories();
           LoggerDescriptor[] loggers = profile.getType().getLoggers();
           ArrayList list = new ArrayList();
           for( int i = 0; i < loggers.length; i++ )
  @@ -247,7 +247,7 @@
               }
           }
   
  -        return new CategoriesDescriptor(
  +        return new LoggingDirective(
               categories.getName(),
               categories.getPriority(),
               categories.getTarget(),
  
  
  
  1.8       +7 -4      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/ThreadLocalLifestyleHandler.java
  
  Index: ThreadLocalLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/ThreadLocalLifestyleHandler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ThreadLocalLifestyleHandler.java	24 Oct 2002 04:12:45 -0000	1.7
  +++ ThreadLocalLifestyleHandler.java	18 Nov 2002 10:52:54 -0000	1.8
  @@ -160,14 +160,17 @@
       /**
        * Request for disposal of the manager.  This operation is normally invoked
        * by the client that initialy instantiated the manager.  The implementation
  -     * handles the disposal of the singleton resoruce and release of associated
  +     * handles the disposal of the singleton resorouce and release of associated
        * references.
        */
       public void dispose()
       {
  -        handleShutdown( m_instance.get() );
  -
  -        m_instance = null;
  +        if( m_instance != null )
  +        {
  +            Object object = m_instance.get();
  +            handleShutdown( object );
  +            m_instance = null;
  +        }
           m_profile = null;
           m_manager = null;
   
  
  
  

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