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/28 18:22:51 UTC

cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource DefaultResource.java

mcconnell    2002/08/28 09:22:51

  Modified:    assembly default.properties
               assembly/src/java/org/apache/excalibur/merlin/assembly
                        DefaultLoggerManager.java
               assembly/src/java/org/apache/excalibur/merlin/container
                        Container.java ContainerFactory.java
                        ContainerService.java DefaultContainer.java
                        StateEvent.java
               assembly/src/java/org/apache/excalibur/merlin/kernel
                        DefaultKernel.java
               assembly/src/java/org/apache/excalibur/merlin/resource
                        DefaultResource.java
  Log:
  Build file updates to sync. with Fortress build plus misc. code updates.
  
  Revision  Changes    Path
  1.10      +2 -0      jakarta-avalon-excalibur/assembly/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/default.properties,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- default.properties	27 Aug 2002 11:42:21 -0000	1.9
  +++ default.properties	28 Aug 2002 16:22:50 -0000	1.10
  @@ -109,6 +109,8 @@
   conf.dir = ${src.dir}/conf
   test.dir = ${src.dir}/test
   
  +tools.dir=${basedir}/../../jakarta-avalon/tools
  +
   #  Set the properties for distribution directories
   dist.dir = dist
   dist.javadocs = ${dist.dir}/docs/api
  
  
  
  1.10      +2 -0      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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultLoggerManager.java	23 Aug 2002 09:23:02 -0000	1.9
  +++ DefaultLoggerManager.java	28 Aug 2002 16:22:50 -0000	1.10
  @@ -87,6 +87,7 @@
   
      /**
       * Creation of a new LoggerManager.
  +    * @param base the base directory
       * @exception Exception is an error occurs
       */
       public DefaultLoggerManager( File base ) throws Exception
  @@ -100,6 +101,7 @@
      /**
       * Creation of a new LoggerManager.
       * @param descriptor the logging system description
  +    * @param base the base directory
       * @exception Exception is an error occurs
       */
       public DefaultLoggerManager( final LoggingDescriptor descriptor, File base ) throws Exception
  
  
  
  1.16      +3 -10     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/Container.java
  
  Index: Container.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/Container.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Container.java	22 Aug 2002 13:43:01 -0000	1.15
  +++ Container.java	28 Aug 2002 16:22:50 -0000	1.16
  @@ -95,13 +95,6 @@
       static final String SERVICES_KEY = "merlin:container.services";
   
      /**
  -    * Return the container name.
  -    *
  -    * @return the name of the container
  -    */
  -    String getName();
  -
  -   /**
       * Return the current state of the container.
       *
       * @return the container state
  @@ -109,11 +102,11 @@
       int getState();
   
      /**
  -    * Returns the set of subsidiary continers container within this container.
  +    * Returns the set of subsidiary continers contained within this container.
       *
       * @return the containers
       */
  -    Container[] getContainers();
  +    //Container[] getContainers();
   
      /**
       * Post-assembly function that returns the set of resources 
  
  
  
  1.5       +11 -5     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContainerFactory.java	22 Aug 2002 10:44:05 -0000	1.4
  +++ ContainerFactory.java	28 Aug 2002 16:22:50 -0000	1.5
  @@ -27,8 +27,11 @@
   import org.apache.excalibur.merlin.resource.LifestyleManager;
   
   /**
  - * Utility class that provides support for the creation of subsidiary containers
  - * based on configuration criteria or meta-data.
  + * Utility class that provides support for the creation of containers
  + * based on configuration criteria or meta-data. A ContainerFactory 
  + * provides support for the establishment of subsidiary containers 
  + * relative to a parent (where the parant may be kerenl or parent
  + * container).
    *
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
    * @version $Revision$ $Date$
  @@ -118,7 +121,9 @@
       }
   
      /**
  -    * Utility to create an subsidiary container manager.
  +    * 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.
       *
       * @param descriptor the subsidiary container descriptor
       * @param classpath the classpath descriptor
  @@ -151,7 +156,8 @@
   
      /**
       * Create a container descriptor and associated manager using a supplied
  -    * configuration.
  +    * configuration and associates these under a ContainerService instance.
  +    *
       * @param config the container configuration
       * @return the fully populated <code>ContainerDescriptor</code>
       * @exception Exception if an error occurs
  
  
  
  1.5       +29 -54    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ContainerService.java
  
  Index: ContainerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/ContainerService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContainerService.java	22 Aug 2002 13:43:01 -0000	1.4
  +++ ContainerService.java	28 Aug 2002 16:22:50 -0000	1.5
  @@ -25,8 +25,12 @@
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
    * @version $Revision$ $Date$
    */
  -public class ContainerService
  +public class ContainerService 
   {
  +    //====================================================================
  +    // state
  +    //====================================================================
  +
      /**
       * The container resource.
       */
  @@ -46,11 +50,10 @@
       * Subsidiary services.
       */
       private Map m_services;
  -   
  -   /**
  -    * The container resource.
  -    */
  -    private Resource m_resource;
  +
  +    //====================================================================
  +    // constructor
  +    //====================================================================
      
      /**
       * Creation of a new container service instance.
  @@ -94,60 +97,21 @@
           m_services = services;
       }
   
  -   /**
  -    * Return the container descriptor.
  -    * @return the container descriptor
  -    */
  -    public ContainerDescriptor getDescriptor()
  -    {
  -        return m_descriptor;
  -    }
  -
  -   /**
  -    * Return the container manager.
  -    * @return the container manager
  -    */
  -    public ContainerManager getManager()
  -    {
  -        return m_manager;
  -    }
  +    //====================================================================
  +    // implementation
  +    //====================================================================
   
      /**
  -    * Returns the container as a resource reference.
  -    * @return the container as a resource reference
  -    * @exception AssemblyException if an error occurs while attempting to 
  -    *   assemble the container
  -    */
  -    public Resource getResource()
  -      throws AssemblyException
  -    {
  -        return getResource( null );
  -    }
  -
  -   /**
  -    * Returns the container as a resource reference.
  -    * @param listener a state listener to assign to the container
  -    * @return the container as a resource reference
  -    * @exception AssemblyException if an error occurs while attempting to 
  -    *   assemble the container
  -    */
  -    public Resource getResource( StateListener listener )
  -      throws AssemblyException
  -    {
  -        return getResource( listener, null );
  -    }
  -
  -   /**
  -    * Returns the container as a resource reference.
  +    * Returns the established container instance.
       * @param stateListener a state listener to assign to the container
       * @param containerListener a container listener to assign to the container
       * @return the container as a resource reference
  -    * @exception AssemblyException if an error occurs while attempting to 
  +    * @exception Exception if an error occurs while attempting to 
       *   assemble the container
       */
  -    public Resource getResource( StateListener stateListener, 
  +    public Container getContainerInstance( StateListener stateListener, 
         ContainerListener containerListener )
  -      throws AssemblyException
  +      throws Exception
       {
           //
           // create the container context
  @@ -174,7 +138,8 @@
               // resolved and return a reference to the container
               //
   
  -            return m_manager.assemble( m_descriptor, context );
  +            Resource resource = m_manager.assemble( m_descriptor, context );
  +            return (Container) resource.access();
           }
           catch( Throwable e )
           {
  @@ -184,4 +149,14 @@
               throw new AssemblyException( error, e );
           }
       }
  +
  +   /**
  +    * Return the container descriptor.
  +    * @return the container descriptor
  +    */
  +    protected ContainerDescriptor getDescriptor()
  +    {
  +        return m_descriptor;
  +    }
  +
   }
  
  
  
  1.36      +26 -23    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.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- DefaultContainer.java	27 Aug 2002 11:08:26 -0000	1.35
  +++ DefaultContainer.java	28 Aug 2002 16:22:50 -0000	1.36
  @@ -114,11 +114,16 @@
   
      /**
       * The thread that this container will run within - established during initialization
  -    * follwing which the container manager is associated as the container's context 
  +    * following which the container manager is associated as the container's context 
       * classloader.
       */
       private Thread m_thread;
   
  +   /**
  +    * The thread group holding the threads of the subsidiary containers.
  +    */
  +    private ThreadGroup m_threadGroup;
  +
       private ContainerFactory m_factory;
   
       private DefaultLoggerManager m_logging;
  @@ -243,8 +248,8 @@
   
      /**
       * Initalization of a <code>Container</code>.  The implementation launches
  -    * a new thread of execution within which the primary initalization actions
  -    * are undertaken during which all declared component {@link Profile} 
  +    * a new thread of execution that handles the primary initalization actions
  +    * during which all declared component {@link Profile} 
       * and subsidiary {@link ContainerDescriptor} instances are added to the 
       * container model.  Component profiles are assembled using the 
       * container {@link ContainerManager}, followed by the creation and 
  @@ -291,7 +296,7 @@
       {
           if( m_manager == null )
           {
  -          throw new IllegalStateException("Container has not been contextualized.");
  +            throw new IllegalStateException("Container has not been contextualized.");
           }
           Thread.currentThread().setContextClassLoader( m_manager );
           try
  @@ -374,12 +379,13 @@
                     + descriptor.getName();
                   throw new IllegalStateException( error );
               }
  -            Resource resource = service.getResource( this );
  -            resource.access();
  +            //Resource resource = service.getResource( this );
  +            //resource.access();
  +            service.getContainerInstance( this, null );
           }
   
           m_state = INITIALIZED;
  -        fireStateChange( new StateEvent( this, INITIALIZED ) );
  +        fireStateChange( new StateEvent( this, getName(), INITIALIZED ) );
       }
   
       //======================================================================
  @@ -511,7 +517,7 @@
           m_manager.start( m_map.getStartupGraph() );
   
           //
  -        // statup all of the subsidiary containers
  +        // startup all of the subsidiary containers
           //
   
           synchronized( m_containers )
  @@ -529,7 +535,7 @@
   
           m_state = STARTED;
           getLogger().debug("container startup complete");
  -        fireStateChange( new StateEvent( this, STARTED ) );
  +        fireStateChange( new StateEvent( this, getName(), STARTED ) );
       }
   
      /**
  @@ -578,7 +584,7 @@
                       {
                           final String warning = 
                             "Failed to stop sub-container: " 
  -                          + ((Container)next).getName();
  +                          + ((Container)next);
                           getLogger().warn( warning, e );
                       }
                   }
  @@ -594,7 +600,7 @@
   
           m_state = STOPPED;
           getLogger().debug("container shutdown complete");
  -        fireStateChange( new StateEvent( this, STOPPED ) );
  +        fireStateChange( new StateEvent( this, getName(), STOPPED ) );
       }
   
       private void handleSuspend()
  @@ -642,7 +648,7 @@
   
           getLogger().debug("container suspension complete");
           m_state = SUSPENDED;
  -        fireStateChange( new StateEvent( this, SUSPENDED ) );
  +        fireStateChange( new StateEvent( this, getName(), SUSPENDED ) );
       }
   
       private void handleResume()
  @@ -698,7 +704,7 @@
   
           getLogger().debug("container resumption complete");
           m_state = STARTED;
  -        fireStateChange( new StateEvent( this, STARTED ) );
  +        fireStateChange( new StateEvent( this, getName(), STARTED ) );
       }
   
       //=======================================================================
  @@ -729,7 +735,7 @@
                   synchronized( m_containers )
                   {
                       getLogger().debug(
  -                      "removing subsidiary container: " + container.getName() );
  +                      "removing subsidiary container: " + event.getName() );
                       m_containers.remove( container );
                   }
                   fireStructuralChange( 
  @@ -746,7 +752,7 @@
       *
       * @return the name of the container
       */
  -    public String getName()
  +    private String getName()
       {
           return m_descriptor.getName();
       }
  @@ -852,7 +858,7 @@
       *
       * @return the containers
       */
  -    public Container[] getContainers()
  +    protected Container[] getContainers()
       {
           synchronized( m_containers )
           {
  @@ -966,7 +972,7 @@
   
           getLogger().debug("done");
           m_state = DISPOSED;
  -        fireStateChange( new StateEvent( this, DISPOSED, error ) );
  +        fireStateChange( new StateEvent( this, getName(), DISPOSED, error ) );
       }
   
       //=======================================================================
  @@ -1052,7 +1058,6 @@
           return addContainer( name, new ClasspathDescriptor() );
       }
   
  -
      /**
       * Creation of a new empty container associated as a subsidiary of this container
       * using the same container profile as this container.
  @@ -1085,8 +1090,7 @@
           }
   
           ContainerService service = m_factory.build( config );
  -        Resource resource = service.getResource( this );
  -        return (Container) resource.access();
  +        return service.getContainerInstance( this, null );
       }
   
      /**
  @@ -1108,8 +1112,7 @@
           }
   
           ContainerService service = m_factory.build( descriptor, classpath );
  -        Resource resource = service.getResource( this );
  -        return (Container) resource.access();
  +        return service.getContainerInstance( this, null );
       }
   
      /**
  
  
  
  1.5       +21 -4     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StateEvent.java	22 Aug 2002 13:43:01 -0000	1.4
  +++ StateEvent.java	28 Aug 2002 16:22:50 -0000	1.5
  @@ -33,6 +33,11 @@
       */
       private Throwable m_error;
   
  +   /**
  +    * The name of the container.
  +    */
  +    private String m_name;
  +
       //============================================================
       // constructor
       //============================================================
  @@ -41,26 +46,29 @@
       * Creation of a new StateEvent.
       *
       * @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}
       */
  -    public StateEvent( Container container, int state ) 
  +    public StateEvent( Container container, String name, int state ) 
       {
  -        this( container, state, null );
  +        this( container, name, state, null );
       }
   
      /**
       * Creation of a new StateEvent.
       *
       * @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 error an error condition triggering the state change
       */
  -    public StateEvent( Container container, int state, Throwable error ) 
  +    public StateEvent( Container container, String name, int state, Throwable error ) 
       {
           super( container );
           m_state = state;
  +        m_name = name;
           m_error = error;
       }
   
  @@ -75,6 +83,15 @@
       public Container getContainer()
       {
           return (Container) getSource();
  +    }
  +
  +   /**
  +    * Returns the name of the container raising the event.
  +    * @return the container name
  +    */
  +    public String getName()
  +    {
  +        return m_name;
       }
   
      /**
  
  
  
  1.46      +4 -5      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.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- DefaultKernel.java	23 Aug 2002 09:23:03 -0000	1.45
  +++ DefaultKernel.java	28 Aug 2002 16:22:51 -0000	1.46
  @@ -235,6 +235,7 @@
      /**
       * Configuration of the kernel.
       * @param config the configuration
  +    * @exception ConfigurationException if an error occurs during configuration
       */
       public void configure( Configuration config ) throws ConfigurationException
       {
  @@ -302,9 +303,8 @@
               factory.enableLogging( m_logger );
   
               ContainerService service = factory.build( config );
  -            Resource resource = service.getResource();
  +            m_container = service.getContainerInstance( null, null );
   
  -            m_container = (Container) resource.access();
               m_initialized = true;
               return;
           }
  @@ -441,9 +441,8 @@
               factory.enableLogging( m_logger );
   
               ContainerService service = factory.build( config );
  -            Resource resource = service.getResource();
  +            m_container = service.getContainerInstance( null, null );
   
  -            m_container = (Container) resource.access();
               getLogger().info("kernel initialization complete");
               m_initialized = true;
           }
  
  
  
  1.7       +18 -3     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultResource.java	23 Aug 2002 06:25:13 -0000	1.6
  +++ DefaultResource.java	28 Aug 2002 16:22:51 -0000	1.7
  @@ -23,12 +23,19 @@
    */
   public class DefaultResource extends AbstractLogEnabled implements Resource
   {
  +    //==========================================================================
  +    // static
  +    //==========================================================================
   
      /**
       * Resource path header element.
       */
       public static final String HEADER = "service:";
   
  +    //==========================================================================
  +    // state
  +    //==========================================================================
  +
       /**
        * The path of the profile designator.
        */
  @@ -49,8 +56,12 @@
        */
       private final LifestyleHandler m_handler;
   
  +    //==========================================================================
  +    // constructor
  +    //==========================================================================
  +
       /**
  -     * Create a new resoruce instance.
  +     * Create a new resource instance.
        *
        * @param path the container path
        * @param profile the resource's profile
  @@ -88,6 +99,10 @@
           m_handler = handler;
       }
   
  +    //==========================================================================
  +    // implementation
  +    //==========================================================================
  +
       /**
        * Returns the path of the resource.
        *
  @@ -119,7 +134,7 @@
       }
   
       /**
  -     * Access an instance.
  +     * Access a fully established service instance.
        *
        * @return the service instance.
        * @exception Exception if an error occurs while establishing the object
  
  
  

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