You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2002/08/31 16:54:01 UTC

cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground CustomContainer.java SimpleComponent.java

mcconnell    2002/08/31 07:54:00

  Modified:    assembly build.xml
               assembly/src/etc demo.mf kernel.xml
               assembly/src/java/org/apache/excalibur/merlin/assembly
                        ContainerManager.java
               assembly/src/java/org/apache/excalibur/merlin/container
                        ContainerFactory.java StateEvent.java
               assembly/src/java/org/apache/excalibur/merlin/kernel
                        DefaultKernel.java Kernel.java
               assembly/src/java/org/apache/excalibur/merlin/model
                        ContainerDescriptor.java Profile.java
               assembly/src/java/org/apache/excalibur/merlin/resource
                        AbstractLifestyleHandler.java DefaultResource.java
                        DeploymentHelper.java
                        SingletonLifestyleHandler.java
               assembly/src/java/org/apache/excalibur/playground
                        CustomContainer.java SimpleComponent.java
  Log:
  Updates supporting rationalization of the thread seperation for a container
  and the modifications to the Container general interface.
  
  Revision  Changes    Path
  1.54      +4 -4      jakarta-avalon-excalibur/assembly/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/build.xml,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- build.xml	23 Aug 2002 09:23:02 -0000	1.53
  +++ build.xml	31 Aug 2002 14:53:59 -0000	1.54
  @@ -407,10 +407,10 @@
       </target>
   
     <target name="patch">
  -    <replace dir="src/xdocs" 
  -       token="subs1"
  -       value="s2" >
  -     <include name="**/*.xml"/>
  +    <replace dir="src/java" 
  +       token="org.apache.excalibur.merlin.resource.ContainerResource"
  +       value="org.apache.excalibur.merlin.container.ContainerResource" >
  +     <include name="**/*.java"/>
       </replace>
     </target>
   
  
  
  
  1.2       +0 -3      jakarta-avalon-excalibur/assembly/src/etc/demo.mf
  
  Index: demo.mf
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/demo.mf,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- demo.mf	21 Aug 2002 01:42:28 -0000	1.1
  +++ demo.mf	31 Aug 2002 14:54:00 -0000	1.2
  @@ -25,8 +25,5 @@
   Name: org/apache/excalibur/playground/DemoManager.class
   Avalon: Type
   
  -Name: org/apache/excalibur/playground/EmbeddedDemo.class
  -Avalon: Type
  -
   Name: org/apache/excalibur/playground/CustomContainer.class
   Avalon: Type
  
  
  
  1.40      +3 -17     jakarta-avalon-excalibur/assembly/src/etc/kernel.xml
  
  Index: kernel.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/kernel.xml,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- kernel.xml	27 Aug 2002 11:08:26 -0000	1.39
  +++ kernel.xml	31 Aug 2002 14:54:00 -0000	1.40
  @@ -10,7 +10,7 @@
     b) multiple candidate resolution
     c) lifestyle support
     d) lifecycle extension
  -  e) embeded kernel creation
  +  e) custom containers
     f) dynamic component addition
     g) context management
     h) configuration management
  @@ -142,9 +142,9 @@
        child container instances.
        -->
   
  -     <container name="sub" class="org.apache.excalibur.playground.CustomContainer">
  +     <container name="custom" class="org.apache.excalibur.playground.CustomContainer">
   
  -       <categories priority="INFO">
  +       <categories priority="DEBUG">
            <category priority="WARN"  name="loader" />
          </categories>
   
  @@ -174,20 +174,6 @@
                <message>This is a custom message.</message>
              </configuration>
   
  -         </component>
  -
  -
  -         <!--
  -         Demonstration of a component that contains an embedded kernel that programatically
  -         adds a container or two, and a new component type.  To enable this demo - change the 
  -         enabled attribute on the component element to true.
  -         -->
  -         <component name="embedder" 
  -           class="org.apache.excalibur.playground.EmbeddedDemo" enabled="true" activation="true">
  -           <categories priority="INFO"/>
  -           <context>
  -             <import key="avalon:home" name="avalon:home"/>
  -           </context>
            </component>
   
          </container>
  
  
  
  1.29      +27 -5     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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- ContainerManager.java	27 Aug 2002 11:08:26 -0000	1.28
  +++ ContainerManager.java	31 Aug 2002 14:54:00 -0000	1.29
  @@ -22,6 +22,7 @@
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.excalibur.merlin.resource.ResourceException;
   import org.apache.excalibur.merlin.resource.DefaultResource;
  +import org.apache.excalibur.merlin.container.ContainerResource;
   import org.apache.excalibur.merlin.container.Container;
   import org.apache.excalibur.merlin.resource.LifestyleHandler;
   import org.apache.excalibur.merlin.resource.LifestyleManager;
  @@ -377,12 +378,12 @@
               if( profile.getActivationPolicy() )
               {
                   Resource resource = getResource( profile );
  -                getLocalLogger().info( profile + " [activating]"); 
  +                getLogger().debug( profile + " [activating]"); 
                   resource.access();
               }
               else
               {
  -                getLocalLogger().info( profile + " [deferred]"); 
  +                getLogger().debug( profile + " [deferred]"); 
               }
           }
       }
  @@ -766,6 +767,10 @@
           {
               throw new NullPointerException("selector");
           }
  +        if( reference == null )
  +        {
  +            throw new NullPointerException("reference");
  +        }
   
           Profile[] profiles = getProfiles( reference );
           return selector.select( profiles );
  @@ -864,8 +869,16 @@
               LifestyleManager lifestyles = getLifestyleManager();
               LifestyleHandler handler =
                 lifestyles.getHandler( this, m_deployment, m_helper, profile, c );
  -            DefaultResource res = 
  -              new DefaultResource( getPath(), profile, context, handler );
  +            DefaultResource res;
  +
  +            if( profile instanceof ContainerDescriptor )
  +            {
  +                res = new ContainerResource( this, profile, context, handler );
  +            }
  +            else
  +            {
  +                res = new DefaultResource( this, profile, context, handler );
  +            }
               res.enableLogging( getLocalLogger().getChildLogger( "resource" ) );
               m_resources.put( profile, res );
               return res;
  @@ -1208,5 +1221,14 @@
                   logger.info( lead + "(empty)" );
               }
           }
  +    }
  +
  +   /**
  +    * Returns a string representation of the manager.
  +    * @return a string holding the container path
  +    */
  +    public String toString()
  +    {
  +       return "ContainerManager: " + getPath();
       }
   }
  
  
  
  1.6       +46 -29    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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ContainerFactory.java	28 Aug 2002 16:22:50 -0000	1.5
  +++ ContainerFactory.java	31 Aug 2002 14:54:00 -0000	1.6
  @@ -10,11 +10,13 @@
   
   import java.util.Map;
   import java.util.Hashtable;
  +import java.util.ArrayList;
   
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.excalibur.meta.info.Type;
   import org.apache.excalibur.merlin.assembly.KernelManager;
   import org.apache.excalibur.merlin.assembly.TypeException;
  @@ -25,6 +27,7 @@
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.builder.XMLContainerCreator;
   import org.apache.excalibur.merlin.resource.LifestyleManager;
  +import org.apache.excalibur.merlin.container.ContainerResource;
   
   /**
    * Utility class that provides support for the creation of containers
  @@ -76,7 +79,7 @@
   
      /**
       * Creation of a container factory that supports the creation of 
  -    * subsidiary containers.
  +    * container reference instances.
       *
       * @param manager the context type manager
       * @param logging the logging manager
  @@ -84,14 +87,13 @@
       public ContainerFactory( 
                           ContainerManager manager, 
                           DefaultLoggerManager logging )
  -       
       {
           this( manager, logging, null );
       }
   
      /**
       * Creation of a container factory that supports the creation of 
  -    * subsidiary containers.
  +    * new container references.
       *
       * @param manager the context type manager
       * @param logging the logging manager
  @@ -121,9 +123,10 @@
       }
   
      /**
  -    * Creation of a ContainerService based on a container descriptor and classpath
  -    * definition.  The ContainerService returned from this is a holder of the resources
  -    * required to establish a new container instance.
  +    * Creation of a ContainerReference based on a container descriptor and classpath
  +    * definition.  The ContainerReference returned from this is a delegate to an 
  +    * actual container and manages the execution of the container under a seperate
  +    * thread of execution.
       *
       * @param descriptor the subsidiary container descriptor
       * @param classpath the classpath descriptor
  @@ -132,7 +135,7 @@
       * @exception Exception is an error occurs
       * @exception NullPointerException if the descriptor or classpath argument is null
       */
  -    public ContainerService build( 
  +    public ContainerResource build( 
                            ContainerDescriptor descriptor, 
                            ClasspathDescriptor classpath ) 
         throws Exception, NullPointerException
  @@ -150,19 +153,18 @@
           final ContainerManager manager = 
             m_manager.createContainerManager( descriptor, classpath, m_lifestyles );
   
  -        return new ContainerService( m_logging, descriptor, manager, new Hashtable() );
  +        return createContainerResource( descriptor, manager, new Hashtable() );
       }
   
   
      /**
  -    * Create a container descriptor and associated manager using a supplied
  -    * configuration and associates these under a ContainerService instance.
  +    * Create a container resource.
       *
       * @param config the container configuration
  -    * @return the fully populated <code>ContainerDescriptor</code>
  +    * @return the <code>ContainerResource</code>
       * @exception Exception if an error occurs
       */
  -    public ContainerService build( Configuration config )
  +    public ContainerResource build( Configuration config )
         throws Exception
       {
   
  @@ -223,27 +225,19 @@
               //
   
               Map map = new Hashtable();
  +            ContainerFactory factory = new ContainerFactory( manager, m_logging );
  +            factory.enableLogging( getLogger().getChildLogger( descriptor.getName() ) );
  +
               Configuration[] containers = config.getChildren("container");
               for( int i=0; i<containers.length; i++ )
               {
                   final Configuration container = containers[i];
  -                ContainerFactory factory = new ContainerFactory( manager, m_logging );
  -                if( m_manager instanceof KernelManager )
  -                {
  -                    factory.enableLogging( getLogger() );
  -                }
  -                else
  -                {
  -                    factory.enableLogging( getLogger().getChildLogger( descriptor.getName() ) );
  -                }
  -
  -                ContainerService service = factory.build( container );
  -                ContainerDescriptor d = service.getDescriptor();
  -                descriptor.addContainer( d );
  -                map.put( d, service );
  +                ContainerResource resource = factory.build( container );
  +                ContainerDescriptor child = (ContainerDescriptor) resource.getProfile();
  +                descriptor.addContainer( child );
  +                map.put( child, resource );
               }
  -
  -            return new ContainerService( m_logging, descriptor, manager, map );
  +            return createContainerResource( descriptor, manager, map );
   
           }
           catch( Throwable e )
  @@ -251,5 +245,28 @@
               final String error = "Error building container descriptor.";
               throw new ContainerException( error, e );
           }
  +    }
  +
  +    private ContainerResource createContainerResource( 
  +                     ContainerDescriptor descriptor, 
  +                     ContainerManager manager, 
  +                     Map services ) throws Exception
  +    {
  +        //
  +        // create the container context
  +        //
  +
  +        DefaultContext context = new DefaultContext();
  +        context.put( Container.MANAGER_KEY, manager );
  +        context.put( Container.DESCRIPTOR_KEY, descriptor );
  +        context.put( Container.LOGGING_KEY, m_logging );
  +        context.put( Container.SERVICES_KEY, services );
  +
  +        //
  +        // assemble the descriptor to ensure that all dependecies are 
  +        // resolved and return a reference to the container
  +        //
  +
  +        return (ContainerResource) m_manager.assemble( descriptor, context );
       }
   }
  
  
  
  1.6       +45 -5     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/StateEvent.java
  
  Index: StateEvent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/StateEvent.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StateEvent.java	28 Aug 2002 16:22:50 -0000	1.5
  +++ StateEvent.java	31 Aug 2002 14:54:00 -0000	1.6
  @@ -18,6 +18,46 @@
    */
   public class StateEvent extends EventObject
   {
  +    //============================================================
  +    // static
  +    //============================================================
  +
  +   /**
  +    * Static state enumeration value indicating that the state of a container is unknown.
  +    */
  +    public static final int UNKNOWN = 0;
  +
  +   /**
  +    * Static state enumeration value indicating that a container has been initialized, 
  +    * all of its subsidiary containers have been initialized, and all component profiles
  +    * have been assembled.
  +    */
  +    public static final int INITIALIZED = 1;
  +
  +   /**
  +    * Static state enumeration value indicating that a container has completed
  +    * lifecycle processing on all components requesting startup establishment.
  +    */
  +    public static final int STARTED = 2;
  +
  +   /**
  +    * Static state enumeration value indicating that a container has been suspended.
  +    */
  +    public static final int SUSPENDED = 3;
  +
  +   /**
  +    * Static state enumeration value indicating that a container has completed
  +    * the shutdown of all subsidiary containers and the internal components 
  +    * have been shutdown.
  +    */
  +    public static final int STOPPED = 4;
  +
  +   /**
  +    * Static state enumeration value indicating that a container and all
  +    * subsidiary containers have been disposed of.
  +    */
  +    public static final int DISPOSED = 5;
  +
   
       //============================================================
       // state
  @@ -47,8 +87,8 @@
       *
       * @param container the source container
       * @param name the name of the soource container
  -    * @param state int value of (@link Container#INITIALIZED}, {@link Container#STARTED}, 
  -    *    {@link Container#SUSPENDED}, {@link Container#STOPPED} or {@link Container#DISPOSED}
  +    * @param state int value of (@link #INITIALIZED}, {@link #STARTED}, 
  +    *    {@link #SUSPENDED}, {@link #STOPPED} or {@link #DISPOSED}
       */
       public StateEvent( Container container, String name, int state ) 
       {
  @@ -60,8 +100,8 @@
       *
       * @param container the source container
       * @param name the name of the soource container
  -    * @param state int value of (@link Container#INITIALIZED}, {@link Container#STARTED}, 
  -    *    {@link Container#STOPPED} or {@link Container#DISPOSED}
  +    * @param state int value of (@link #INITIALIZED}, {@link #STARTED}, 
  +    *    {@link #STOPPED} or {@link #DISPOSED}
       * @param error an error condition triggering the state change
       */
       public StateEvent( Container container, String name, int state, Throwable error ) 
  
  
  
  1.47      +21 -19    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.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- DefaultKernel.java	28 Aug 2002 16:22:51 -0000	1.46
  +++ DefaultKernel.java	31 Aug 2002 14:54:00 -0000	1.47
  @@ -29,7 +29,11 @@
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.excalibur.event.command.TPCThreadManager;
   import org.apache.excalibur.event.command.CommandManager;
  -import org.apache.excalibur.meta.verifier.VerifyException;
  +import org.apache.excalibur.merlin.assembly.ContainerManager;
  +import org.apache.excalibur.merlin.assembly.KernelManager;
  +import org.apache.excalibur.merlin.assembly.DefaultLoggerManager;
  +import org.apache.excalibur.merlin.container.Container;
  +import org.apache.excalibur.merlin.container.ContainerFactory;
   import org.apache.excalibur.merlin.model.verifier.AssemblyVerifier;
   import org.apache.excalibur.merlin.model.verifier.MetaDataVerifier;
   import org.apache.excalibur.merlin.model.builder.XMLContainerCreator;
  @@ -39,14 +43,10 @@
   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.assembly.ContainerManager;
  -import org.apache.excalibur.merlin.assembly.KernelManager;
  -import org.apache.excalibur.merlin.assembly.DefaultLoggerManager;
  -import org.apache.excalibur.merlin.container.Container;
  -import org.apache.excalibur.merlin.container.ContainerService;
  -import org.apache.excalibur.merlin.container.ContainerFactory;
  +import org.apache.excalibur.merlin.container.ContainerResource;
   import org.apache.excalibur.merlin.resource.LifestyleManager;
   import org.apache.excalibur.merlin.resource.DefaultLifestyleManager;
  +import org.apache.excalibur.meta.verifier.VerifyException;
   import org.apache.excalibur.mpool.DefaultPoolManager;
   import org.apache.excalibur.mpool.PoolManager;
   
  @@ -285,6 +285,7 @@
           final Configuration config = m_config.getChild("container");
           String name = config.getAttribute("name");
   
  +
           //
           // If this kernel has been created inside container scope then
           // all we need to do is to setup a root container that the client
  @@ -294,6 +295,7 @@
           if( classloader instanceof ContainerManager )
           {
               ContainerManager manager = (ContainerManager) classloader;
  +System.out.println("## creating a nested kernel in: " + manager );
   
               m_base = manager.getPath().replace('/','.').substring(1) + "." + name;
               m_logger = getLoggingManager().getLoggerForCategory( m_base );
  @@ -302,8 +304,8 @@
               ContainerFactory factory = new ContainerFactory( manager, getLoggingManager() );
               factory.enableLogging( m_logger );
   
  -            ContainerService service = factory.build( config );
  -            m_container = service.getContainerInstance( null, null );
  +            ContainerResource resource = factory.build( config );
  +            m_container = (Container) resource.access();
   
               m_initialized = true;
               return;
  @@ -440,8 +442,8 @@
                 new ContainerFactory( m_manager, getLoggingManager(), lifestyles );
               factory.enableLogging( m_logger );
   
  -            ContainerService service = factory.build( config );
  -            m_container = service.getContainerInstance( null, null );
  +            ContainerResource resource = factory.build( config );
  +            m_container = (Container) resource.access();
   
               getLogger().info("kernel initialization complete");
               m_initialized = true;
  @@ -598,13 +600,13 @@
       * Returns the set of resoruces established within the container hierachy
       * @return the resource collection
       */
  -    public Resource[] getResources()
  -    {
  -        synchronized( m_container )
  -        {
  -            return m_container.getResources();
  -        }
  -    }
  +    //public Resource[] getResources()
  +    //{
  +    //    synchronized( m_container )
  +    //    {
  +    //        return m_container.getResources();
  +    //    }
  +    //}
   
      /**
       * Internal verification of the container.
  
  
  
  1.15      +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Kernel.java
  
  Index: Kernel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Kernel.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Kernel.java	23 Aug 2002 09:23:03 -0000	1.14
  +++ Kernel.java	31 Aug 2002 14:54:00 -0000	1.15
  @@ -51,6 +51,6 @@
        *
        * @return the set of resource designators
        */
  -    Resource[] getResources();
  +    //Resource[] getResources();
       
   }
  
  
  
  1.15      +4 -3      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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ContainerDescriptor.java	23 Aug 2002 06:25:13 -0000	1.14
  +++ ContainerDescriptor.java	31 Aug 2002 14:54:00 -0000	1.15
  @@ -117,11 +117,12 @@
        * Create a ContainerDescriptor instance using an existing descriptor as a template.
        *
        * @param name the abstract name of container descriptor
  +     * @param activation the activation policy
        * @param template the template descritptor
        */
  -    public ContainerDescriptor( final String name, final ContainerDescriptor template )
  +    public ContainerDescriptor( final String name, final boolean activation, final ContainerDescriptor template )
       {
  -        super( name, template );
  +        super( name, activation, template );
       }
   
       /**
  
  
  
  1.25      +10 -9     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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Profile.java	23 Aug 2002 06:25:13 -0000	1.24
  +++ Profile.java	31 Aug 2002 14:54:00 -0000	1.25
  @@ -220,10 +220,10 @@
        * Create a Profile instance without parameters.
        *
        * @param name the abstract name of profile
  +     * @param activation the profile activation policy
        * @param template the profile to use as a template
        */
  -    public Profile( final String name,
  -                           final Profile template )
  +    public Profile( final String name, boolean activation, final Profile template )
       {
           this( 
             name, 
  @@ -233,8 +233,8 @@
             template.getCategories(), 
             template.getType(), 
             template.isEnabled(), 
  -          template.getActivationPolicy(), 
  -          template.getMode() );
  +          activation, 
  +          EXPLICIT );
       }
   
   
  @@ -261,6 +261,11 @@
                              final boolean activation,
                              final int mode )
       {
  +        if( null == type )
  +        {
  +            throw new NullPointerException( "type" );
  +        }
  +
           if( null == name )
           {
               m_name = type.getInfo().getName() + "#" + System.identityHashCode( this );
  @@ -277,10 +282,6 @@
               }
           }
   
  -        if( null == type )
  -        {
  -            throw new NullPointerException( "type" );
  -        }
           if( null == categories )
           {
               throw new NullPointerException( "categories" );
  
  
  
  1.9       +32 -1     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/AbstractLifestyleHandler.java
  
  Index: AbstractLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/AbstractLifestyleHandler.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractLifestyleHandler.java	23 Aug 2002 06:25:13 -0000	1.8
  +++ AbstractLifestyleHandler.java	31 Aug 2002 14:54:00 -0000	1.9
  @@ -15,6 +15,7 @@
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.context.Context;
   import org.apache.excalibur.container.lifecycle.Accessor;
  +import org.apache.excalibur.merlin.container.Container;
   import org.apache.excalibur.merlin.assembly.ContainerManager;
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.Resource;
  @@ -30,15 +31,46 @@
   public abstract class AbstractLifestyleHandler extends AbstractLogEnabled 
     implements LifestyleHandler, Disposable
   {
  +    /**
  +     * Deployment profile to apply.
  +     */
        private Profile m_profile;
  +
  +    /**
  +     * Type manager to be used and in the case of a runnable target, the type
  +     * manager to assign as the context classloader.
  +     */
        private ContainerManager m_manager;
  +
  +    /**
  +     * Utility class to help out with component deployment.
  +     */
        private DeploymentHelper m_deployment;
  +
  +    /**
  +     * Utility class to help out with component lifecycle processing.
  +     */
        private LifecycleHelper m_helper;
  +
  +    /**
  +     * The base context from which import directives can be resolved.
  +     */
        private Context m_context;
   
  +    /**
  +     * Utility class that handles establishment of things like component
  +     * configuration, context, loggers, managers, etc.
  +     */
        private ResourceProvider m_provider;
  +
  +    /**
  +     * The class of the object we are handling.
  +     */
        private Class m_class;
   
  +    /**
  +     * Flag indicating the internal status of the handler.
  +     */
        private boolean m_initialized = false;
   
       /**
  @@ -266,7 +298,6 @@
           final String path = m_manager.getPath() + "/" + m_profile.getName();
           m_helper.startup( path, m_profile, object, m_provider );
           return object;
  -
        }
   
       /**
  
  
  
  1.8       +10 -8     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultResource.java
  
  Index: DefaultResource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultResource.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultResource.java	28 Aug 2002 16:22:51 -0000	1.7
  +++ DefaultResource.java	31 Aug 2002 14:54:00 -0000	1.8
  @@ -13,6 +13,7 @@
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.Resource;
   import org.apache.excalibur.meta.info.ServiceDescriptor;
  +import org.apache.excalibur.merlin.assembly.ContainerManager;
   
   
   /**
  @@ -39,7 +40,7 @@
       /**
        * The path of the profile designator.
        */
  -    private final String m_path;
  +    private final ContainerManager m_manager;
   
       /**
        * The profile that disignator refers to.
  @@ -63,19 +64,19 @@
       /**
        * Create a new resource instance.
        *
  -     * @param path the container path
  +     * @param manager the container type manager
        * @param profile the resource's profile
        * @param context the deployment context
        * @param handler the lifestyle handler
        */
  -    public DefaultResource( final String path,
  +    public DefaultResource( final ContainerManager manager,
                              final Profile profile,
                              final Context context,
                              final LifestyleHandler handler )
       {
  -        if( null == path )
  +        if( null == manager )
           {
  -            throw new NullPointerException( "path" );
  +            throw new NullPointerException( "manager" );
           }
   
           if( null == profile )
  @@ -93,10 +94,11 @@
               throw new NullPointerException( "handler" );
           }
   
  -        m_path = path;
  +        m_manager = manager;
           m_profile = profile;
           m_context = context;
           m_handler = handler;
  +
       }
   
       //==========================================================================
  @@ -110,7 +112,7 @@
        */
       public String getPath()
       {
  -        return HEADER + m_path;
  +        return HEADER + m_manager.getPath() + "/" + m_profile.getName();
       }
   
       /**
  
  
  
  1.5       +6 -0      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DeploymentHelper.java	23 Aug 2002 06:25:13 -0000	1.4
  +++ DeploymentHelper.java	31 Aug 2002 14:54:00 -0000	1.5
  @@ -119,6 +119,12 @@
           try
           {
               classname = profile.getType().getInfo().getImplementationKey();
  +
  +            getLogger().debug( "load profile: " + profile.getName() 
  +              + "' in thread: '" + Thread.currentThread().getName()
  +              + "' context manager: '" + Thread.currentThread().getContextClassLoader()
  +              + "' using: " + m_manager.getPath() );
  +
               return m_manager.loadClass( classname );
           }
           catch( Throwable e )
  
  
  
  1.8       +11 -1     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/SingletonLifestyleHandler.java
  
  Index: SingletonLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/SingletonLifestyleHandler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SingletonLifestyleHandler.java	23 Aug 2002 06:57:48 -0000	1.7
  +++ SingletonLifestyleHandler.java	31 Aug 2002 14:54:00 -0000	1.8
  @@ -23,9 +23,19 @@
    */
   public class SingletonLifestyleHandler extends AbstractLifestyleHandler 
   {
  +    /**
  +     * The profile of the component being managed.
  +     */
        private Profile m_profile;
  +
  +    /**
  +     * The type manager to use.
  +     */
        private ContainerManager m_manager;
   
  +    /**
  +     * Internal reference to the singleton object.
  +     */
        private Object m_object;
   
       /**
  @@ -73,7 +83,7 @@
   
       /**
        * Invoked by a client to return an instance of the object type previously 
  -     * supported by the manager.  The singleton manager does nothing as the 
  +     * created by the manager.  The singleton manager does nothing as the 
        * object may be used across an arbitary number of clients.
        * 
        * @param object the object to return
  
  
  
  1.3       +51 -0     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/CustomContainer.java
  
  Index: CustomContainer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/CustomContainer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CustomContainer.java	22 Aug 2002 05:01:57 -0000	1.2
  +++ CustomContainer.java	31 Aug 2002 14:54:00 -0000	1.3
  @@ -2,7 +2,11 @@
   
   package org.apache.excalibur.playground;
   
  +import org.apache.excalibur.merlin.assembly.ContainerManager;
   import org.apache.excalibur.merlin.container.DefaultContainer;
  +import org.apache.excalibur.merlin.container.ContainerException;
  +import org.apache.excalibur.merlin.model.Profile;
  +import org.apache.excalibur.meta.info.ReferenceDescriptor;
   
   /**
    * This is a minimal validation of the creation of a custom container.  More
  @@ -26,6 +30,53 @@
       {
           getLogger().info("initialization of a custom container");
           super.initialize();
  +
  +        ContainerManager manager;
  +        if( Thread.currentThread().getContextClassLoader() instanceof ContainerManager )
  +        {
  +            manager = (ContainerManager) Thread.currentThread().getContextClassLoader();
  +            getLogger().info("customer container manager: " + manager.getPath() );
  +        }
  +        else
  +        {
  +            final String error = "Attempting to execute demo outside of a container context.";
  +            throw new IllegalStateException( error );
  +        }
  +
  +        Profile template = manager.getProfile( 
  +          new ReferenceDescriptor( "org.apache.excalibur.playground.SimpleService" ) );
  +        if( template == null )
  +        {
  +            final String error = "Unable to locate a template profile for SimpleService";
  +            throw new Exception( error );
  +        }
  +
  +        //
  +        // install a new profile based on the template into the container triggering 
  +        // profile assembly
  +        //
  +
  +        Profile profile = new Profile("dynamic", true, template );
  +        if( profile != null )
  +        {
  +            getLogger().info( "dynamic profile: " + profile );
  +            install( new Profile[]{ profile } );
  +            getLogger().info("installation sucessfull" );
  +        }
  +        else
  +        {
  +            final String error = "manager return a null profile - cannot proceed";
  +            throw new ContainerException( error );          
  +        }
       }
   
  +   /**
  +    * Implementation of the container startup procedure. 
  +    * @exception Exception if an error occurs during the startup phase
  +    */
  +    public void start() throws Exception
  +    {
  +        getLogger().info( "startup of the custom container" );
  +        super.start();
  +    }
   }
  
  
  
  1.4       +2 -0      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/SimpleComponent.java
  
  Index: SimpleComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/SimpleComponent.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SimpleComponent.java	22 Aug 2002 13:43:02 -0000	1.3
  +++ SimpleComponent.java	31 Aug 2002 14:54:00 -0000	1.4
  @@ -11,6 +11,7 @@
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.activity.Startable;
   import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.excalibur.merlin.assembly.ContainerManager;
   
   /**
    * This is a minimal demonstration component that a dependency on 
  @@ -102,6 +103,7 @@
       public void initialize()
       {
           getLogger().debug("initialize");
  +        getLogger().info("context type manager: " + Thread.currentThread().getContextClassLoader() );
           doObjective();
       }
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>