avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl DefaultFactory.java DefaultKernel.java
Date Wed, 07 Jan 2004 16:07:17 GMT
mcconnell    2004/01/07 08:07:17

  Modified:    merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl
                        Tag: Ver_3_4 AbstractBlock.java Deployer.java
               merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl
                        Tag: Ver_3_4 DefaultFactory.java DefaultKernel.java
  Log:
  Synchronize merlin kernel with activation.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.10.2.4  +3 -1      avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/AbstractBlock.java
  
  Index: AbstractBlock.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/AbstractBlock.java,v
  retrieving revision 1.10.2.3
  retrieving revision 1.10.2.4
  diff -u -r1.10.2.3 -r1.10.2.4
  --- AbstractBlock.java	7 Jan 2004 12:57:25 -0000	1.10.2.3
  +++ AbstractBlock.java	7 Jan 2004 16:07:17 -0000	1.10.2.4
  @@ -292,6 +292,7 @@
               ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
               ClassLoader classloader = model.getClassLoaderModel().getClassLoader();
               Thread.currentThread().setContextClassLoader( classloader );
  +
               Deployer deployer = 
                 new Deployer( getLogger().getChildLogger( "deployer" ) );
   
  @@ -310,6 +311,7 @@
                   // restore the Old ContextClassloader.
                   Thread.currentThread().setContextClassLoader( oldCL );
               }
  +
               m_deployment.setEnabled( true );
           }
       }
  
  
  
  1.2.2.2   +22 -11    avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/Deployer.java
  
  Index: Deployer.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/Deployer.java,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- Deployer.java	7 Jan 2004 12:57:25 -0000	1.2.2.1
  +++ Deployer.java	7 Jan 2004 16:07:17 -0000	1.2.2.2
  @@ -56,10 +56,14 @@
   
   import org.apache.avalon.framework.logger.Logger;
   
  -/**
  - * Runnable deployment thread.
  + * Runnable deployment thread that handles the deployment of an 
  + * arbitary number of deployable instances.  The deployer maintains a 
  + * list of deployment requests which are queued on a first come first 
  + * serve basis.
  + *
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    * @version $Revision$ $Date$
  + * @see DeploymentRequest
    */
   class Deployer
       implements Runnable
  @@ -101,16 +105,23 @@
       // implementation
       //------------------------------------------------------------
   
  -    /** Deploys the given Deployable, and allows a maximum time
  -     *  for the deployment to complete.
  -     * @throws DeploymentException if the deployment hanged, but the
  -     * thread interruption was successful.
  -     * @throws FatalDeploymentException if the deployment hanged, and
  -     * the thread interruption failed.
  -     * @throws Exception any Exception or Error thrown by within the
  -     * deployment of the component is forwarded to the caller.
  +    /** 
  +     * Deploys the given Deployable, and allows a maximum time
  +     * for the deployment to complete.
  +     *
  +     * @param deployable the deployable appliance
  +     * @param timeout the maximum time to allow for deployment
  +     *
  +     * @throws DeploymentException if the deployment was not 
  +     *   completed within the timeout deadline and interuption
  +     *   of the deployment was successful
  +     * @throws FatalDeploymentException if the deployment was not 
  +     *   completed within the timeout deadline and interuption
  +     *   of the deployment was not successful
  +     * @throws Exception any Exception or Error thrown within the
  +     *   deployment of the component is forwarded to the caller.
        * @throws InvocationTargetException if the deployment throws a
  -     * Throwable subclass that is NOT of type Exception or Error.
  +     *   Throwable subclass that is NOT of type Exception or Error.
        **/
       void deploy( Deployable deployable, long timeout )
           throws Exception
  
  
  
  No                   revision
  No                   revision
  1.7.2.4   +41 -73    avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java
  
  Index: DefaultFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java,v
  retrieving revision 1.7.2.3
  retrieving revision 1.7.2.4
  diff -u -r1.7.2.3 -r1.7.2.4
  --- DefaultFactory.java	4 Jan 2004 17:23:17 -0000	1.7.2.3
  +++ DefaultFactory.java	7 Jan 2004 16:07:17 -0000	1.7.2.4
  @@ -61,9 +61,7 @@
   
   import org.apache.avalon.activation.appliance.Block;
   import org.apache.avalon.activation.appliance.BlockContext;
  -import org.apache.avalon.activation.appliance.Composite;
   import org.apache.avalon.activation.appliance.impl.AbstractBlock;
  -import org.apache.avalon.activation.appliance.impl.DefaultServiceContext;
   
   import org.apache.avalon.composition.data.ContainmentProfile;
   import org.apache.avalon.composition.data.CategoriesDirective;
  @@ -87,6 +85,7 @@
   import org.apache.avalon.composition.model.ClassLoaderModel;
   import org.apache.avalon.composition.model.ModelRepository;
   import org.apache.avalon.composition.model.impl.DefaultSystemContext;
  +import org.apache.avalon.composition.model.impl.DelegatingSystemContext;
   import org.apache.avalon.composition.model.impl.DefaultModelFactory;
   import org.apache.avalon.composition.model.impl.DefaultContainmentContext;
   import org.apache.avalon.composition.model.impl.DefaultContainmentModel;
  @@ -103,6 +102,7 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  +import org.apache.avalon.framework.parameters.Parameters;
   
   import org.apache.avalon.merlin.Kernel;
   import org.apache.avalon.merlin.KernelException;
  @@ -375,12 +375,20 @@
             "repository established: " + repository );
   
           //
  +        // create the <parameters>
  +        //
  +
  +        Configuration paramsConfig = kernelConfig.getChild( "parameters" );
  +        Parameters params = Parameters.fromConfiguration(
  +            paramsConfig, "parameter" );
  +
  +        //
           // create the system context
           //
   
           File anchor = criteria.getAnchorDirectory();
   
  -        DefaultSystemContext applicationContext = 
  +        DefaultSystemContext systemContext = 
             new DefaultSystemContext( 
               m_logging,
               anchor,
  @@ -388,7 +396,8 @@
               criteria.getTempDirectory(),
               repository,
               loggingDescriptor.getName(),
  -            criteria.isDebugEnabled() );
  +            criteria.isDebugEnabled(),
  +            params );
   
           //
           // create the application model
  @@ -396,11 +405,11 @@
   
           getLogger().info( "building application model" );
           final Logger applicationLogger = m_logging.getLoggerForCategory("");
  -        ClassLoader api = applicationContext.getCommonClassLoader();
  +        ClassLoader api = systemContext.getCommonClassLoader();
           ContainmentModel application = 
             new DefaultContainmentModel(
               createContainmentContext( 
  -              applicationContext, applicationLogger, api,
  +              systemContext, applicationLogger, api,
                 getContainmentProfile( 
                   kernelConfig.getChild( "container" ) ) ) );
   
  @@ -411,67 +420,44 @@
   
           getLogger().info( "facilities deployment" );
   
  -        Configuration facilities = 
  +        Configuration facilitiesConfig = 
             kernelConfig.getChild( "system" );
   
  -        DefaultSystemContext systemContext = 
  -          new DefaultSystemContext( 
  -            m_logging,
  -            anchor,
  -            criteria.getContextDirectory(),
  -            criteria.getTempDirectory(),
  -            repository,
  -            loggingDescriptor.getName(),
  -            criteria.isDebugEnabled() );
  -
  -        systemContext.put( "urn:merlin:dir", criteria.getWorkingDirectory() );
  -        systemContext.put( "urn:merlin:anchor", criteria.getAnchorDirectory() );
  -        systemContext.put( "urn:merlin:model", application );
  -
  -        systemContext.makeReadOnly();
  +        DelegatingSystemContext facilitiesContext = 
  +          new DelegatingSystemContext( systemContext );
  +        facilitiesContext.put( "urn:merlin:dir", criteria.getWorkingDirectory() );
  +        facilitiesContext.put( "urn:merlin:anchor", criteria.getAnchorDirectory() );
  +        facilitiesContext.put( "urn:merlin:model", application );
  +        facilitiesContext.makeReadOnly();
   
           ClassLoader spi = BlockContext.class.getClassLoader();
           final Logger systemLogger = getLogger();
  -        ContainmentModel system = 
  +        ContainmentModel facilities = 
             new DefaultContainmentModel(
               createContainmentContext( 
  -              systemContext, systemLogger, spi,
  -              getContainmentProfile( facilities ) ) );
  -
  -        //
  -        // TODO: now that the system context is established we 
  -        // need to create a block and supply the system block
  -        // (perhaps under a service manager) to the new model
  -        // model factory to ensure that new system services 
  -        // established under system scope override the bootstrap 
  -        // facilities
  -        //
  +              facilitiesContext, systemLogger, spi,
  +              getContainmentProfile( facilitiesConfig ) ) );
   
  -        DefaultServiceContext services = new DefaultServiceContext();
  -        services.put( LoggingManager.KEY, m_logging );
  +        try
  +        {
  +            getLogger().debug( "system assembly" );
  +            facilities.assemble();
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +             "Facilities assembly failure.";
  +            throw new KernelException( error, e );
  +        }
   
           try
           {
  -            m_system = AbstractBlock.createRootBlock( services, system );
  -            if( m_system instanceof Composite )
  -            {
  -                try
  -                {
  -                    getLogger().debug( "system assembly" );
  -                    ((Composite)m_system).assemble();
  -                }
  -                catch( Throwable e )
  -                {
  -                    final String error = 
  -                      "Facilities assembly failure.";
  -                    throw new KernelException( error, e );
  -                }
  -            }
  +            m_system = AbstractBlock.createRootBlock( facilitiesContext, facilities );
           }
           catch( Throwable e )
           {
               final String error = 
  -              "Facilities composition failure.";
  +              "Facilities establishment failure.";
               throw new KernelException( error, e );
           }
   
  @@ -541,29 +527,11 @@
           }
   
           //
  -        // instantiate the runtime root application block
  -        //
  -        getLogger().info( "deployment" );
  -
  -        getLogger().debug( "activation phase" );
  -        try
  -        {
  -            m_application = 
  -              AbstractBlock.createRootBlock( services, application );
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Composition failure.";
  -            throw new KernelException( error, e );
  -        }
  -
  -        //
           // instantiate the kernel
           //
   
           Kernel kernel = 
  -          createKernel( getLogger(), criteria, m_system, m_application );
  +          createKernel( getLogger(), criteria, systemContext, application );
           setShutdownHook( getLogger(), kernel );
           if( criteria.isAutostartEnabled() )
           {
  @@ -603,13 +571,13 @@
       }
   
       private Kernel createKernel(
  -      Logger logger, KernelCriteria criteria, Block system, Block application )
  +      Logger logger, KernelCriteria criteria, SystemContext context, ContainmentModel application
)
         throws KernelException
       {
           try
           {
               return new DefaultKernel( 
  -              logger, criteria, system, application );
  +              logger, criteria, context, application );
           }
           catch( Throwable e )
           {
  
  
  
  1.1.2.2   +54 -61    avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultKernel.java
  
  Index: DefaultKernel.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/impl/DefaultKernel.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- DefaultKernel.java	4 Jan 2004 17:23:17 -0000	1.1.2.1
  +++ DefaultKernel.java	7 Jan 2004 16:07:17 -0000	1.1.2.2
  @@ -59,17 +59,20 @@
   import org.apache.avalon.merlin.KernelCriteria;
   import org.apache.avalon.merlin.KernelException;
   import org.apache.avalon.merlin.KernelRuntimeException;
  +
   import org.apache.avalon.activation.appliance.Appliance;
   import org.apache.avalon.activation.appliance.Block;
   import org.apache.avalon.activation.appliance.Composite;
   import org.apache.avalon.activation.appliance.impl.AbstractBlock;
  -import org.apache.avalon.activation.appliance.impl.DefaultServiceContext;
  +
   import org.apache.avalon.composition.data.TargetDirective;
   import org.apache.avalon.composition.logging.LoggingManager;
   import org.apache.avalon.composition.model.ContainmentContext;
   import org.apache.avalon.composition.model.ContainmentModel;
   import org.apache.avalon.composition.model.ComponentModel;
  +import org.apache.avalon.composition.model.SystemContext;
   import org.apache.avalon.composition.util.StringHelper;
  +
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.logger.Logger;
   
  @@ -107,9 +110,9 @@
   
       private final KernelCriteria m_criteria;
   
  -    private final Block m_system;
  +    private final SystemContext m_context;
   
  -    private final Block m_application;
  +    private final ContainmentModel m_model;
   
       private final DefaultState m_self = new DefaultState();
   
  @@ -123,6 +126,8 @@
   
       private long m_stateChangeSequenceId = 0;
   
  +    private Block m_application;
  +
       //--------------------------------------------------------------
       // constructor
       //--------------------------------------------------------------
  @@ -132,27 +137,27 @@
       * @param logger the assigned logging channel
       * @param criteria the kernel creation criteria
       * @param system the system block
  -    * @param application the application block
  +    * @param mosdel the application model
       * @exception KernelException if a kernel creation error occurs
       */
       public DefaultKernel( 
         final Logger logger,
         final KernelCriteria criteria, 
  -      final Block system, 
  -      final Block application ) throws KernelException
  +      final SystemContext context,
  +      final ContainmentModel model ) throws KernelException
       {
           if( logger == null ) 
             throw new NullPointerException( "logger" );
           if( criteria == null ) 
             throw new NullPointerException( "criteria" );
  -        if( system == null ) 
  -          throw new NullPointerException( "system" );
  -        if( application == null ) 
  -          throw new NullPointerException( "application" );
  +        if( context == null ) 
  +          throw new NullPointerException( "context" );
  +        if( model == null ) 
  +          throw new NullPointerException( "model" );
   
           m_criteria = criteria;
  -        m_system = system;
  -        m_application = application;
  +        m_context = context;
  +        m_model = model;
           m_logger = logger;
   
           setState( INITIALIZED );
  @@ -160,7 +165,7 @@
           if( getLogger().isDebugEnabled() )
           {
               int count = 
  -              m_application.getContainmentModel().getModels().length;
  +              m_model.getModels().length;
               if( count == 0 )
               {
                   getLogger().debug( "kernel established" );
  @@ -345,6 +350,11 @@
       */
       public Appliance locate( String path ) throws KernelException
       {
  +        if( null == m_application )
  +        {
  +            throw new IllegalStateException( "not-started" );
  +        }
  +
           try
           {
               return m_application.locate( path );
  @@ -377,30 +387,37 @@
       */
       public void startup() throws Exception
       {
  +        //
  +        // instantiate the runtime root application block
  +        //
  +
           synchronized( m_self )
           {
               if( m_self.isEnabled() ) return;
  +            setState( ASSEMBLY );
  +            try
  +            {
  +                getLogger().debug( "application assembly" );
  +                m_model.assemble();
  +            }
  +            catch( Throwable e )
  +            {
  +                final String error = 
  +                  "Application assembly failure.";
  +                throw new KernelException( error, e );
  +            }
   
  -            //
  -            // we have a model established and we now need to go though the process
  -            // of appliance establishment
  -            //
  -
  -            if( m_application instanceof Composite )
  +            try
               {
  -                setState( ASSEMBLY );
  -                try
  -                {
  -                    getLogger().debug( "assembly phase" );
  -                    ((Composite)m_application).assemble();
  -                }
  -                catch( Throwable e )
  -                {
  -                    setState( INITIALIZED );
  -                    final String error = 
  -                      "Application assembly failure.";
  -                    throw new KernelException( error, e );
  -                }
  +                m_application = 
  +                  AbstractBlock.createRootBlock( m_context, m_model );
  +                setState( INITIALIZED );
  +            }
  +            catch( Throwable e )
  +            {
  +                final String error = 
  +                  "Application establishment failure.";
  +                throw new KernelException( error, e );
               }
   
               Throwable cause = null;
  @@ -471,19 +488,16 @@
   
                   try
                   {
  -                    if( m_application instanceof Composite )
  -                    {
  -                        setState( DISSASSEMBLY );
  -                        getLogger().info( "dissassembly phase" );
  -                        ((Composite)m_application).disassemble();
  -                    }
  +                    setState( DISSASSEMBLY );
  +                    getLogger().info( "dissassembly phase" );
  +                    m_model.disassemble();
                   }
                   catch( Throwable e )
                   {
                       if( getLogger().isWarnEnabled() )
                       {
                           final String error =
  -                          "Ignoring block dissassembly error.";
  +                          "Ignoring application dissassembly error.";
                           getLogger().warn( error, e );
                       }
                   }
  @@ -499,27 +513,6 @@
               m_self.setEnabled( false );
           }
       }
  -
  -                /*
  -                setState( BLOCK_DISPOSAL );
  -                try
  -                {
  -                    if( m_block instanceof Disposable )
  -                    {
  -                        getLogger().info( "disposal phase" );
  -                        ((Disposable)m_block).dispose();
  -                    }
  -                }
  -                catch( Throwable e )
  -                {
  -                    if( getLogger().isWarnEnabled() )
  -                    {
  -                        final String error =
  -                          "Ignoring block disposal error.";
  -                        getLogger().warn( error, e );
  -                    }
  -                }
  -                */
   
       //--------------------------------------------------------------
       // internal
  
  
  

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


Mime
View raw message