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 2003/09/05 11:59:27 UTC

cvs commit: avalon-sandbox/merlin/kernel/spi/src/java/org/apache/avalon/merlin/kernel Controller.java Kernel.java KernelContext.java

mcconnell    2003/09/05 02:59:27

  Modified:    merlin/kernel/bootstrap/src/etc merlin.properties
               merlin/kernel/bootstrap/src/java Merlin.java
               merlin/kernel/impl project.xml
               merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl
                        CLIKernelLoader.java DefaultKernel.java
                        DefaultKernelContext.java Resources.properties
               merlin/kernel/spi/src/java/org/apache/avalon/merlin/kernel
                        Kernel.java KernelContext.java
  Added:       merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl
                        DefaultKernelMBean.java JRMPKernelAdaptor.java
               merlin/kernel/spi/src/java/org/apache/avalon/merlin/kernel
                        Controller.java
  Log:
  Updates incorporating initial support for JMX at the kernel level.  These additions enable restarting of a set of blocks via JMX and inspection of kernal attributes.
  
  Revision  Changes    Path
  1.11      +2 -3      avalon-sandbox/merlin/kernel/bootstrap/src/etc/merlin.properties
  
  Index: merlin.properties
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/kernel/bootstrap/src/etc/merlin.properties,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- merlin.properties	1 Sep 2003 02:18:13 -0000	1.10
  +++ merlin.properties	5 Sep 2003 09:59:26 -0000	1.11
  @@ -7,7 +7,6 @@
   #
   # the api classpath
   #
  -merlin.api.classpath.length=5
   merlin.api.classpath.0=avalon-framework:avalon-framework-api;SNAPSHOT
   merlin.api.classpath.1=avalon-meta:avalon-meta-api;SNAPSHOT
   merlin.api.classpath.2=avalon-composition:avalon-composition-api;SNAPSHOT
  @@ -17,7 +16,6 @@
   #
   # the spi classpath
   #
  -merlin.spi.classpath.length=6
   merlin.spi.classpath.0=avalon-meta:avalon-meta-spi;SNAPSHOT
   merlin.spi.classpath.1=avalon-extension:avalon-extension-spi;SNAPSHOT
   merlin.spi.classpath.2=avalon-composition:avalon-composition-spi;SNAPSHOT
  @@ -28,7 +26,6 @@
   #
   # the bootstrap classpath
   #
  -merlin.impl.classpath.length=12
   merlin.impl.classpath.0=avalon-framework:avalon-framework-impl;SNAPSHOT
   merlin.impl.classpath.1=avalon-meta:avalon-meta-impl;SNAPSHOT
   merlin.impl.classpath.2=avalon-extension:avalon-extension-impl;SNAPSHOT
  @@ -41,3 +38,5 @@
   merlin.impl.classpath.9=logkit:logkit;1.2
   merlin.impl.classpath.10=excalibur-event:excalibur-event;1.0.3
   merlin.impl.classpath.11=excalibur-configuration:excalibur-configuration;1.1-dev
  +merlin.impl.classpath.12=mx4j:mx4j-jmx;1.1.1
  +merlin.impl.classpath.13=mx4j:mx4j-tools;1.1.1
  
  
  
  1.8       +59 -47    avalon-sandbox/merlin/kernel/bootstrap/src/java/Merlin.java
  
  Index: Merlin.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/kernel/bootstrap/src/java/Merlin.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Merlin.java	19 Aug 2003 05:45:15 -0000	1.7
  +++ Merlin.java	5 Sep 2003 09:59:26 -0000	1.8
  @@ -115,7 +115,7 @@
           // the merlin jar repository
           //
   
  -        String fallback =  System.getProperty( "user.home" ) + "/merlin";
  +        String fallback =  System.getProperty( "user.home" ) + "/.merlin";
           String system =  System.getProperty( MERLIN_HOME_KEY, fallback );
           String local = System.getProperty( MERLIN_LOCAL_KEY, system );
           File base = new File( local, "repository" );
  @@ -251,6 +251,26 @@
                 constructor.newInstance( 
                   new Object[]{ repository, args } );
           }
  +        catch( InvocationTargetException e )
  +        {
  +            Throwable target = e.getTargetException();
  +            boolean cliError = 
  +              target.getClass().getName().startsWith( "org.apache.commons.cli" );
  +            if( cliError )
  +            {
  +                System.err.println( "Commandline error: " + target.getMessage() );
  +            }
  +            else
  +            {
  +                final String error =
  +                  "\nInternal error during kernel instantiation.";
  +                String msg = 
  +                  ExceptionHelper.packException( 
  +                    error, target, true );
  +                System.err.println( msg );
  +            }
  +            return;
  +        }
           catch( Throwable e )
           {
               final String error =
  @@ -264,58 +284,50 @@
   
       private static URL[] getURLs( Repository repository, Properties properties, String key )
       {
  -        final String value = properties.getProperty( key + ".length" );
  -        if( value == null )
  +        int i = 0;
  +        ArrayList list = new ArrayList();
  +        String label = getProperty( properties, key, i );
  +        while( label != null )
           {
  -            throw new NullPointerException( value );
  +            list.add( getURL( repository, label ) );
  +            label = getProperty( properties, key, i++ );
           }
  -        int i = Integer.parseInt( value );
  -        return getURLs( repository, properties, key, i );
  +        return (URL[]) list.toArray( new URL[0] );
       }
   
  -    private static URL[] getURLs( 
  -      Repository repository, Properties properties, String label, int i )
  +    private static String getProperty( Properties properties, String key, int i )
       {
  -        ArrayList list = new ArrayList();
  -        for( int j=0; j<i; j++ )
  -        {
  -            final String key = label + "." + j;
  -            final String item = properties.getProperty( key );
  -            if( item == null )
  -            {
  -                final String error = 
  -                  "Inconsistent classpath entry: " + key;
  -                throw new IllegalStateException( error );
  -            }
  -            try
  -            {
  -                int n = item.indexOf( ":" );
  -                final String group = item.substring( 0, n );
  +         final String label = key + "." + i;
  +         return properties.getProperty( label );
  +    }
  +
  +    private static URL getURL( Repository repository, String item )
  +    {
  +         try
  +         {
  +             int n = item.indexOf( ":" );
  +             final String group = item.substring( 0, n );
               
  -                String artifact = null;
  -                String version = null;
  -                int m = item.indexOf( ";" );
  -                if( m > -1 )
  -                {
  -                    artifact = item.substring( n+1, m );
  -                    version = item.substring( m+1, item.length() );
  -                }
  -                else
  -                {
  -                    artifact = item.substring( n+1, item.length() );
  -                }
  +             String artifact = null;
  +             String version = null;
  +             int m = item.indexOf( ";" );
  +             if( m > -1 )
  +             {
  +                 artifact = item.substring( n+1, m );
  +                 version = item.substring( m+1, item.length() );
  +             }
  +             else
  +             {
  +                 artifact = item.substring( n+1, item.length() );
  +             }
               
  -                URL url = repository.getArtifact( group, artifact, version, "jar" );
  -                list.add( url );
  -            }
  -            catch( Throwable e )
  -            {
  -                final String error = 
  -                  "Internal bootstrap error.  Unable to load item: " + item;
  -                throw new BootstrapRuntimeException( error, e );
  -            }
  -        }
  -
  -        return (URL[]) list.toArray( new URL[0] );
  +             return repository.getArtifact( group, artifact, version, "jar" );
  +         }
  +         catch( Throwable e )
  +         {
  +             final String error = 
  +              "Internal bootstrap error.  Unable to load item: " + item;
  +             throw new BootstrapRuntimeException( error, e );
  +         }
       }
   }
  
  
  
  1.6       +14 -1     avalon-sandbox/merlin/kernel/impl/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/kernel/impl/project.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- project.xml	1 Sep 2003 02:18:13 -0000	1.5
  +++ project.xml	5 Sep 2003 09:59:26 -0000	1.6
  @@ -19,6 +19,19 @@
   
     <dependencies>
   
  +    <!-- mx4j dependecies -->
  +
  +    <dependency>
  +      <groupId>mx4j</groupId>
  +      <artifactId>mx4j-jmx</artifactId>
  +      <version>1.1.1</version>
  +    </dependency>
  +    <dependency>
  +      <groupId>mx4j</groupId>
  +      <artifactId>mx4j-tools</artifactId>
  +      <version>1.1.1</version>
  +    </dependency>
  +    
       <!-- merlin dependecies -->
   
       <dependency>
  @@ -26,7 +39,7 @@
         <artifactId>merlin-kernel-spi</artifactId>
         <version>SNAPSHOT</version>
       </dependency>
  -    
  +
       <!-- avalon dependecies -->
   
       <dependency>
  
  
  
  1.13      +148 -5    avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/CLIKernelLoader.java
  
  Index: CLIKernelLoader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/CLIKernelLoader.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- CLIKernelLoader.java	23 Aug 2003 09:35:45 -0000	1.12
  +++ CLIKernelLoader.java	5 Sep 2003 09:59:26 -0000	1.13
  @@ -13,10 +13,16 @@
   import java.net.MalformedURLException;
   import java.net.URL;
   
  +import javax.management.MBeanServer;
  +import javax.management.MBeanServerFactory;
  +import javax.management.ObjectName;
  +
   import org.apache.avalon.composition.util.ExceptionHelper;
  +import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  +import org.apache.avalon.framework.activity.Startable;
   import org.apache.avalon.merlin.kernel.Kernel;
   import org.apache.avalon.merlin.kernel.KernelContext;
   import org.apache.avalon.merlin.kernel.KernelException;
  @@ -56,7 +62,6 @@
   
       private static Options CL_OPTIONS = buildCommandLineOptions();
   
  -
       //--------------------------------------------------------------------------
       // constructor
       //--------------------------------------------------------------------------
  @@ -72,7 +77,7 @@
           CommandLine line = parser.parse( CL_OPTIONS, args );
   
           //
  -        // check for a language override fromm the commandline
  +        // check for a language override from the commandline
           // and reset the cache if needed
           //
   
  @@ -136,26 +141,129 @@
               return;
           }
   
  +        if( line.hasOption( "jmx" ) )
  +        {
  +            managedStartup( context );
  +        }
  +        else
  +        {
  +            standardStartup( context );
  +        }
  +    }
  +
  +    private boolean managedStartup( KernelContext context )
  +    {
  +        MBeanServer server = MBeanServerFactory.createMBeanServer();
  +        try
  +        {
  +            //mx4j.log.Log.setDefaultPriority( mx4j.log.Logger.DEBUG );
  +
  +            Logger logger = context.getKernelLogger().getChildLogger( "jmx" );
  +            JRMPKernelAdaptor adapter = new JRMPKernelAdaptor( logger, server );
  +            setShutdownHook( adapter );
  +            adapter.start();
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error =
  +              "\nUnexpected error during jmx server establishment.";
  +            String msg = 
  +              ExceptionHelper.packException( error, e, true );
  +            System.err.println( msg );
  +            return false;
  +        }
  +
  +        Kernel kernel = null;
  +        try
  +        {
  +            kernel = createKernel( context );
  +            ObjectName name = new ObjectName( "merlin.kernel:type=kernel" );
  +            server.registerMBean( kernel, name );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Could not establish or registering the kernel.";
  +            String message = ExceptionHelper.packException( error, e );
  +            System.err.println( message );
  +            return false;
  +        }
  +
  +        try
  +        {
  +            kernel.startup();
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Kernel startup failure.";
  +            String message = ExceptionHelper.packException( error, e );
  +            System.err.println( message );
  +            kernel.shutdown();
  +            return false;
  +        }
  +
  +        return true;
  +    }
  +
  +    private boolean standardStartup( KernelContext context )
  +    {
           //
           // ready to roll -
           // create the kernel and set a shutdown hook
           //
   
  +        Kernel kernel = null;
           try
           {
  -            Kernel kernel = new DefaultKernel( context );
  -            setShutdownHook( kernel );
  +            kernel = createKernel( context );
           }
  -        catch( Throwable e )
  +        catch( KernelException e )
           {
               final String error =
                 "\nInternal error during kernel instantiation.";
               String msg = 
                 ExceptionHelper.packException( error, e, context.getDebugFlag() );
               System.err.println( msg );
  +            return false;
  +        }
  +
  +        try
  +        {
  +            kernel.startup();
  +        }
  +        catch( KernelException e )
  +        {
  +            String msg = 
  +              ExceptionHelper.packException( 
  +                e.getMessage(), e.getCause(), context.getDebugFlag() );
  +            System.err.println( msg );
  +            kernel.shutdown();
  +            return false;
  +        }
  +        catch( Throwable e )
  +        {
  +            kernel.shutdown();
  +            final String error =
  +              "\nInternal error during kernel startup.";
  +            String msg = 
  +              ExceptionHelper.packException( error, e, context.getDebugFlag() );
  +            System.err.println( msg );
  +            return false;
           }
  +
  +        return true;
  +    }
  +
  +    private Kernel createKernel( KernelContext context ) throws KernelException
  +    {
  +        Kernel kernel = new DefaultKernel( context );
  +        setShutdownHook( kernel );
  +        return kernel;
       }
   
  +
  +
       //--------------------------------------------------------------------------
       // implementation
       //--------------------------------------------------------------------------
  @@ -317,6 +425,36 @@
           );
       }
   
  +   /**
  +    * Create a shutdown hook that will trigger shutdown of the supplied adapter.
  +    * @param adapter the jmx jrmp adapter
  +    */
  +    private void setShutdownHook( final JRMPKernelAdaptor adapter )
  +    {
  +        //
  +        // Create a shutdown hook to trigger clean disposal of the
  +        // Merlin kernel
  +        //
  +
  +        Runtime.getRuntime().addShutdownHook(
  +          new Thread()
  +          {
  +              public void run()
  +              {
  +                  try
  +                  {
  +                      adapter.stop();
  +                  }
  +                  catch( Throwable e )
  +                  {
  +                      // ignore it
  +                  }
  +              }
  +          }
  +        );
  +    }
  +
  +
       private Configuration getKernelConfiguration( final File file )
         throws ConfigurationException, IOException, SAXException
       {
  @@ -536,6 +674,10 @@
              "info",
              REZ.getString( "cli-info-description" ) );
   
  +        Option jmx = new Option(
  +           "jmx",
  +           REZ.getString( "cli-jmx-description" ) );
  +
           Option locale = OptionBuilder
              .hasArg()
              .withArgName( "code" )
  @@ -578,6 +720,7 @@
           options.addOption( version );
           options.addOption( info );
           options.addOption( debug );
  +        options.addOption( jmx );
           options.addOption( home );
           options.addOption( sys );
           options.addOption( library );
  
  
  
  1.11      +248 -100  avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernel.java
  
  Index: DefaultKernel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernel.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultKernel.java	26 Aug 2003 22:45:25 -0000	1.10
  +++ DefaultKernel.java	5 Sep 2003 09:59:26 -0000	1.11
  @@ -53,10 +53,13 @@
   import java.io.File;
   import java.io.InputStream;
   import java.net.URL;
  +import javax.management.NotificationBroadcasterSupport;
  +import javax.management.AttributeChangeNotification;
   
   import org.apache.avalon.merlin.kernel.Kernel;
   import org.apache.avalon.merlin.kernel.KernelContext;
   import org.apache.avalon.merlin.kernel.KernelException;
  +import org.apache.avalon.merlin.kernel.KernelRuntimeException;
   import org.apache.avalon.activation.appliance.Block;
   import org.apache.avalon.activation.appliance.Composite;
   import org.apache.avalon.activation.appliance.ServiceContext;
  @@ -72,7 +75,6 @@
   import org.apache.avalon.composition.logging.TargetProvider;
   import org.apache.avalon.composition.logging.impl.DefaultLoggingManager;
   import org.apache.avalon.composition.model.SystemContext;
  -import org.apache.avalon.composition.model.Model;
   import org.apache.avalon.composition.model.ModelFactory;
   import org.apache.avalon.composition.model.ModelException;
   import org.apache.avalon.composition.model.ContainmentContext;
  @@ -84,7 +86,7 @@
   import org.apache.avalon.composition.util.ExceptionHelper;
   import org.apache.avalon.composition.util.StringHelper;
   import org.apache.avalon.framework.activity.Disposable;
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.excalibur.mpool.PoolManager;
  @@ -94,14 +96,25 @@
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  -public class DefaultKernel extends AbstractLogEnabled implements Kernel
  +public class DefaultKernel extends NotificationBroadcasterSupport 
  +  implements Kernel, DefaultKernelMBean
   {
       //--------------------------------------------------------------
       // static
       //--------------------------------------------------------------
   
  -    private static final XMLContainmentProfileCreator CREATOR = 
  -      new XMLContainmentProfileCreator();
  +    private static final String INITIALIZING = "initializing";
  +    private static final String INITIALIZED = "initialized";
  +    private static final String STARTING = "starting";
  +    private static final String COMPOSITION = "model composition";
  +    private static final String ASSEMBLY = "model assembly";
  +    private static final String DEPLOYMENT = "block deployment";
  +    private static final String STARTED = "started";
  +    private static final String STOPPING = "stopping";
  +    private static final String DECOMMISSIONING = "decommissioning";
  +    private static final String DISSASSEMBLY = "dissassembly";
  +    private static final String BLOCK_DISPOSAL = "block disposal";
  +    private static final String STOPPED = "stopped";
   
       //--------------------------------------------------------------
       // immutable state
  @@ -111,43 +124,34 @@
   
       private final ContainmentModel m_model;
   
  -    private final Block m_block; 
  -
       private final DefaultState m_self = new DefaultState();
   
  +    private final DefaultState m_start = new DefaultState();
  +
  +    private Block m_block;
  +
  +    private String m_stateString = INITIALIZING;
  +
  +    private long m_stateChangeSequenceId = 0;
  +
       //--------------------------------------------------------------
       // constructor
       //--------------------------------------------------------------
   
  -    public DefaultKernel( final KernelContext context ) throws KernelException
  +    public DefaultKernel( final KernelContext context ) 
  +      throws KernelException
       {
           if( context == null ) throw new NullPointerException( "context" );
   
           m_context = context;
   
  -        enableLogging( context.getKernelLogger() );
  -
           //
           // create the root block into which we install application blocks
           //
   
           getLogger().debug( "creating root containment context" );
  -        ContainmentContext contaiment = null;
  -        try
  -        {
  -            final ContainmentProfile profile = 
  -              CREATOR.createContainmentProfile( 
  -            context.getKernelDirective().getChild( "container" ) );
  -
  -            contaiment = context.getModelFactory().createContainmentContext( profile );
  -            Thread.currentThread().setContextClassLoader( contaiment.getClassLoader() );
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Internal error while build default containment context.";
  -            throw new KernelException( error, e );
  -        }
  +        ContainmentContext contaiment = context.getContainmentContext();
  +        Thread.currentThread().setContextClassLoader( contaiment.getClassLoader() );
   
           getLogger().debug( "construction phase" );
   
  @@ -162,8 +166,6 @@
               throw new KernelException( error, e );
           }
   
  -        m_self.setEnabled( true );
  -
           //
           // install any block declared within the kernel context
           //
  @@ -202,7 +204,7 @@
           {
               TargetDirective target = targets[i];
               final String path = target.getPath();
  -            Model model = m_model.getModel( path );
  +            Object model = m_model.getModel( path );
               if( model != null )
               {
                   if( model instanceof DeploymentModel )
  @@ -235,72 +237,109 @@
               }
           }
   
  -        //
  -        // we have a model established and we now need to go though the process
  -        // of appliance establishment
  -        //
  +        setState( INITIALIZED );
  +        getLogger().debug( "kernel established" );
  +    }
   
  -        getLogger().debug( "composition phase" );
  -        try
  -        {
  -            DefaultServiceContext services = new DefaultServiceContext();
  -            services.put( PoolManager.ROLE, context.getPoolManager() );
  -            services.put( LoggingManager.KEY, context.getLoggingManager() );
  -            m_block = DefaultBlock.createRootBlock( services, m_model );
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Composition failure.";
  -            throw new KernelException( error, e );
  -        }
  +    //--------------------------------------------------------------
  +    // DefaultKernelMBean
  +    //--------------------------------------------------------------
   
  -        try
  -        {
  -            if( m_block instanceof Composite )
  -            {
  -                getLogger().debug( "assembly phase" );
  -                ((Composite)m_block).assemble();
  -            }
  -        }
  -        catch( Throwable e )
  -        {
  -            final String error = 
  -              "Assembly failure.";
  -            throw new KernelException( error, e );
  -        }
  +    /**
  +     * Return the state of the kernel.
  +     * @return a string representing the kernel state
  +     */
  +     public String getKernelState()
  +     {
  +         return m_stateString;
  +     }
   
  -        Throwable cause = null;
  -        try
  -        {
  -            getLogger().debug( "deployment phase" );
  -            m_block.deploy();
  -        }
  -        catch( Throwable e )
  +    /**
  +     * Return an approximation to the total amount of memory currently 
  +     * available for future allocated objects, measured in bytes.
  +     * @return the number of bytes of estimated free memory
  +     */
  +    public long getMemoryFree()
  +    {
  +        return Runtime.getRuntime().freeMemory();
  +    }
  +
  +   /**
  +    * Returns the total amount of memory in the Java virtual machine. The value 
  +    * returned by this method may vary over time, depending on the host environment. 
  +    *
  +    * @return the total amount of memory currently available for current and future 
  +    *    objects, measured in bytes.
  +    */
  +    public long getMemoryTotal()
  +    {
  +        return Runtime.getRuntime().totalMemory();
  +    }
  +
  +   /**
  +    * Return the percentage of free memory available.
  +    * @return the free memory percentage
  +    */
  +    public int getMemoryVariableRatio()
  +    {
  +        return (int) ((Runtime.getRuntime().freeMemory() * 100) / Runtime.getRuntime().totalMemory());
  +    }
  +
  +   /**
  +    * Return the number of active threads.
  +    * @return the active thread count
  +    */
  +    public int getThreadCount()
  +    {
  +        return Thread.activeCount();
  +    }
  +
  +   /**
  +    * Return the runtime repository path.
  +    * @return the repository path
  +    */
  +    public String getRepositoryDirectoryPath()
  +    {
  +        return m_context.getRepositoryPath().toString();
  +    }
  +
  +   /**
  +    * Return the home path
  +    * @return the home path (possibly null)
  +    */
  +    public String getHomeDirectoryPath()
  +    {
  +        return m_context.getHomePath().toString();
  +    }
  +
  +   /**
  +    * Return the temporary directory path
  +    * @return the path (possibly null)
  +    */
  +    public String getTempDirectoryPath()
  +    {
  +        return m_context.getTempPath().toString();
  +    }
  +
  +   /**
  +    * Return the library path
  +    * @return the path (possibly null)
  +    */
  +    public String getLibraryDirectoryPath()
  +    {
  +        if( m_context.getLibraryPath() == null )
           {
  -            cause = e;
  -            final String error = 
  -              "Deployment failure.";
  -            throw new KernelException( error, e );
  +            return getHomeDirectoryPath();
           }
  -        finally
  +        else
           {
  -            if( cause != null )
  -            {
  -                shutdown();
  -            }
  -            else if( !context.getServerFlag() )
  -            {
  -                // TODO: add pause parameter
  -
  -                shutdown();
  -            }
  +            return m_context.getLibraryPath().toString();
           }
       }
   
  -    //==============================================================
  +    //--------------------------------------------------------------
       // Home
  -    //==============================================================
  +    //--------------------------------------------------------------
   
       /**
        * Resolve a object to a value.
  @@ -360,32 +399,115 @@
           }
       }
   
  -    //==============================================================
  +    //--------------------------------------------------------------
       // DefaultKernel
  -    //==============================================================
  +    //--------------------------------------------------------------
   
      /**
  -    * Shutdown the kernel during which orderly shutdown of all
  -    * installed blocks is undertaken.
  +    * Initiate the establishment of the root container.
  +    * @exception Exception if a startup error occurs
       */
  -    public void shutdown()
  +    public void startup() throws Exception
       {
           synchronized( m_self )
           {
  -            if( !m_self.isEnabled() ) return;
  +            if( m_self.isEnabled() ) return;
   
  -            if( getLogger() != null )
  +            setState( STARTING );
  +
  +            //
  +            // we have a model established and we now need to go though the process
  +            // of appliance establishment
  +            //
  +
  +            setState( COMPOSITION );
  +
  +            try
  +            {
  +                DefaultServiceContext services = new DefaultServiceContext();
  +                services.put( PoolManager.ROLE, m_context.getPoolManager() );
  +                services.put( LoggingManager.KEY, m_context.getLoggingManager() );
  +                m_block = DefaultBlock.createRootBlock( services, m_model );
  +            }
  +            catch( Throwable e )
  +            {
  +                setState( INITIALIZED );
  +                final String error = 
  +                  "Composition failure.";
  +                throw new KernelException( error, e );
  +            }
  +
  +            if( m_block instanceof Composite )
               {
  -                if( getLogger().isInfoEnabled() )
  +                setState( ASSEMBLY );
  +                try
  +                {
  +                    getLogger().debug( "assembly phase" );
  +                    ((Composite)m_block).assemble();
  +                }
  +                catch( Throwable e )
                   {
  -                    getLogger().info( "decommissioning phase" );
  +                    setState( INITIALIZED );
  +                    final String error = 
  +                      "Assembly failure.";
  +                    throw new KernelException( error, e );
                   }
               }
   
  +            Throwable cause = null;
  +            setState( DEPLOYMENT );
  +            try
  +            {
  +                getLogger().debug( "deployment phase" );
  +                m_block.deploy();
  +            }
  +            catch( Throwable e )
  +            {
  +                setState( INITIALIZED );
  +                cause = e;
  +                final String error = 
  +                  "Deployment failure.";
  +                throw new KernelException( error, e );
  +            }
  +            finally
  +            {
  +                if( cause != null )
  +                {
  +                    shutdown();
  +                }
  +                else if( !m_context.getServerFlag() )
  +                {
  +                    setState( STARTED );
  +                    // TODO: add pause parameter
  +                    shutdown();
  +                }
  +                else
  +                {
  +                    setState( STARTED );
  +                }
  +            }
  +            m_self.setEnabled( true );
  +        }
  +    }
  +
  +   /**
  +    * Shutdown the kernel during which orderly shutdown of all
  +    * installed blocks is undertaken.
  +    */
  +    public void shutdown()
  +    {
  +        synchronized( m_self )
  +        {
  +            if( !m_self.isEnabled() ) return;
  +
  +            setState( STOPPING );
  +
  +
               if( m_block != null )
               {
                   try
                   {
  +                    setState( DECOMMISSIONING );
                       m_block.decommission();
                   }
                   catch( Throwable e )
  @@ -402,6 +524,7 @@
                   {
                       if( m_block instanceof Composite )
                       {
  +                        setState( DISSASSEMBLY );
                           getLogger().info( "dissassembly phase" );
                           ((Composite)m_block).disassemble();
                       }
  @@ -416,6 +539,7 @@
                       }
                   }
   
  +                setState( BLOCK_DISPOSAL );
                   try
                   {
                       if( m_block instanceof Disposable )
  @@ -438,17 +562,36 @@
               if( getLogger().isDebugEnabled() )
               {
                   int n = Thread.activeCount();
  -                getLogger().info( "bye (" + n + ")" );
  -            }
  -            else if( getLogger().isInfoEnabled() )
  -            {
  -                getLogger().info( "bye" );
  +                getLogger().debug( "active threads (" + n + ")" );
               }
   
  +            setState( STOPPED );
               m_self.setEnabled( false );
           }
       }
   
  +    //--------------------------------------------------------------
  +    // internal
  +    //--------------------------------------------------------------
  +
  +    /**
  +     * Set the state of the kernel.
  +     * @param a string representing the kernel state
  +     */
  +     private void setState( String state )
  +     {
  +         if( m_stateString.equals( state ) ) return;
  +         getLogger().debug( "state: " + state );
  +         String old = m_stateString;
  +         m_stateString = state;
  +         long id = m_stateChangeSequenceId++;
  +         AttributeChangeNotification notification = 
  +           new AttributeChangeNotification( 
  +             this, id, System.currentTimeMillis(),
  +             "State change", "state", "string", old, state );
  +         sendNotification( notification );
  +     }
  +
       private class DefaultState
       {
           private boolean m_enabled = false;
  @@ -470,5 +613,10 @@
           {
               m_enabled = enabled;
           }
  +    }
  +
  +    private Logger getLogger()
  +    {
  +        return m_context.getKernelLogger();
       }
   }
  
  
  
  1.22      +59 -21    avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernelContext.java
  
  Index: DefaultKernelContext.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernelContext.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DefaultKernelContext.java	25 Aug 2003 16:41:04 -0000	1.21
  +++ DefaultKernelContext.java	5 Sep 2003 09:59:26 -0000	1.22
  @@ -56,12 +56,14 @@
   import java.util.Enumeration;
   import java.io.InputStream;
   
  -import org.apache.avalon.composition.data.builder.XMLDeploymentProfileCreator;
   import org.apache.avalon.composition.data.CategoryDirective;
   import org.apache.avalon.composition.data.CategoriesDirective;
  +import org.apache.avalon.composition.data.ContainmentProfile;
   import org.apache.avalon.composition.data.Targets;
   import org.apache.avalon.composition.data.TargetDirective;
   import org.apache.avalon.composition.data.builder.XMLTargetsCreator;
  +import org.apache.avalon.composition.data.builder.XMLDeploymentProfileCreator;
  +import org.apache.avalon.composition.data.builder.XMLContainmentProfileCreator;
   import org.apache.avalon.composition.logging.LoggingManager;
   import org.apache.avalon.composition.logging.LoggingDescriptor;
   import org.apache.avalon.composition.logging.TargetDescriptor;
  @@ -69,6 +71,8 @@
   import org.apache.avalon.composition.logging.impl.DefaultLoggingManager;
   import org.apache.avalon.composition.logging.impl.FileTargetProvider;
   import org.apache.avalon.composition.model.ModelFactory;
  +import org.apache.avalon.composition.model.ContainmentContext;
  +import org.apache.avalon.composition.model.impl.DefaultContainmentContext;
   import org.apache.avalon.composition.model.impl.DefaultSystemContext;
   import org.apache.avalon.composition.model.impl.DefaultModelFactory;
   import org.apache.avalon.composition.util.StringHelper;
  @@ -95,16 +99,20 @@
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  -public class DefaultKernelContext extends AbstractLogEnabled implements KernelContext
  +public class DefaultKernelContext extends AbstractLogEnabled 
  +  implements KernelContext
   {
  -    //==============================================================
  +    //--------------------------------------------------------------
       // static
  -    //==============================================================
  +    //--------------------------------------------------------------
   
       public static final String PRODUCT = "Merlin SMP";
   
       public static final String VERSION = "3.0";
   
  +    private static final XMLContainmentProfileCreator CONTAINER_CREATOR = 
  +      new XMLContainmentProfileCreator();
  +
       private static final XMLDeploymentProfileCreator CREATOR = 
         new XMLDeploymentProfileCreator();
   
  @@ -153,11 +161,6 @@
       /**
        * The kernel configuration url.
        */
  -    private final Configuration m_kernel;
  -
  -    /**
  -     * The kernel configuration url.
  -     */
       private final String m_kernelURL;
   
       /**
  @@ -202,6 +205,8 @@
   
       private final Logger m_kernelLogger;
   
  +    private final ContainmentContext m_root;
  +
       //--------------------------------------------------------------
       // constructor
       //--------------------------------------------------------------
  @@ -242,14 +247,14 @@
           m_working = new File( home, "home" );
           m_temp = new File( System.getProperty( "java.io.tmpdir" ) );
   
  +        Configuration kernelConfig = null;
           if( kernel != null )
           {
               m_kernelURL = kernel.toString();
  -            m_kernel = getKernelConfiguration( kernel );
  +            kernelConfig = getKernelConfiguration( kernel );
           }
           else
           {
  -            Configuration kernelConfig = null;
               String kernelURL = null;
               try
               {
  @@ -278,7 +283,6 @@
                       throw new KernelException( error, ee );
                   }
               }
  -            m_kernel = kernelConfig;
               m_kernelURL = kernelURL;
           }
   
  @@ -301,7 +305,7 @@
           // as the directive source
           //
   
  -        Configuration conf = m_kernel.getChild( "logging" );
  +        Configuration conf = kernelConfig.getChild( "logging" );
           LoggingDescriptor logging = createLoggingDescriptor( conf );
           m_logging = bootstrapLoggingManager( home, logging, debug );
           m_kernelLogger = m_logging.getLoggerForCategory( logging.getName() );
  @@ -325,16 +329,16 @@
   
           if( system != null )
           {
  -            Configuration repositoryConfig = m_kernel.getChild( "repository" );
  +            Configuration repositoryConfig = kernelConfig.getChild( "repository" );
               m_repository = createRepository( system, repositoryConfig );
               getLogger().debug( "repository established" );
           }
           else
           {
  -            if( m_kernel.getChild( "repository", false ) != null )
  +            if( kernelConfig.getChild( "repository", false ) != null )
               {
                   File repo = getSystemDefaultDirectory();
  -                Configuration repositoryConfig = m_kernel.getChild( "repository" );
  +                Configuration repositoryConfig = kernelConfig.getChild( "repository" );
                   getLogger().debug( "using kernel defined repository" );
                   m_repository = createRepository( repo, repositoryConfig );
               }
  @@ -374,6 +378,24 @@
                 "Unexpected exception while creating internal model factory.";
               throw new KernelException( error, e );
           }
  +
  +        //
  +        // create the root containment context
  +        //
  +
  +        try
  +        {
  +            final ContainmentProfile profile = 
  +              CONTAINER_CREATOR.createContainmentProfile( 
  +                kernelConfig.getChild( "container" ) );
  +            m_root = m_factory.createContainmentContext( profile );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Internal error while build default containment context.";
  +            throw new KernelException( error, e );
  +        }
       }
   
       private Repository createRepository( File root, Configuration config ) 
  @@ -520,7 +542,7 @@
   
      /**
       * Return the home path
  -    * @return the path (possibly null)
  +    * @return the path
       */
       public File getHomePath()
       {
  @@ -537,12 +559,12 @@
       }
   
      /**
  -    * Return the URL for the kernel configuration directive.
  +    * Return the root containment context.
       * @return the kernel directive url
       */
  -    public Configuration getKernelDirective()
  +    public ContainmentContext getContainmentContext()
       {
  -        return m_kernel;
  +        return m_root;
       }
   
      /**
  @@ -606,6 +628,22 @@
       public TargetDirective[] getTargetDirectives()
       {
           return m_targets;
  +    }
  +
  +   /**
  +    * Return the runtime repository directory.
  +    * @return the repository path
  +    */
  +    public File getRepositoryPath()
  +    {
  +        if( m_system != null )
  +        {
  +            return m_system;
  +        }
  +        else
  +        {
  +            return getSystemDefaultDirectory();
  +        }
       }
   
       //--------------------------------------------------------------
  
  
  
  1.6       +2 -0      avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/Resources.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Resources.properties	23 Aug 2003 09:35:45 -0000	1.5
  +++ Resources.properties	5 Sep 2003 09:59:27 -0000	1.6
  @@ -13,6 +13,8 @@
   
   cli-info-description=Lists info about the deployment context.
   
  +cli-jmx-description=Bootstrap Merlin under a JMX server.
  +
   cli-debug-description=Enables debug mode.
   
   cli-home-description=A relative or absolute path to a working home directory. If not suppled, the system will default to the current directory.
  
  
  
  1.1                  avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernelMBean.java
  
  Index: DefaultKernelMBean.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.merlin.kernel.impl;
  
  import org.apache.avalon.merlin.kernel.Controller;
  
  
  /**
   *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/09/05 09:59:27 $
   */
  public interface DefaultKernelMBean extends Controller
  {
      /**
       * Return an approximation to the total amount of memory currently 
       * available for future allocated objects, measured in bytes.
       * @return the number of bytes of estimated free memory
       */
      long getMemoryFree();
  
     /**
      * Returns the total amount of memory in the Java virtual machine. The value 
      * returned by this method may vary over time, depending on the host environment. 
      *
      * @return the total amount of memory currently available for current and 
      *   future objects, measured in bytes.
      */
      long getMemoryTotal();
  
     /**
      * Return the percentage of free memory available.
      * @return the free memory percentage
      */
      int getMemoryVariableRatio();
  
     /**
      * Return the number of active threads.
      * @return the active thread count
      */
      int getThreadCount();
  
     /**
      * Return the state of the kernel.
      * @return a string representing the kernel state
      */
      String getKernelState();
  
     /**
      * Return the runtime repository path.
      * @return the repository path
      */
      public String getRepositoryDirectoryPath();
  
     /**
      * Return the home path
      * @return the home path (possibly null)
      */
      String getHomeDirectoryPath();
  
     /**
      * Return the temporary directory path
      * @return the path (possibly null)
      */
      String getTempDirectoryPath();
  
     /**
      * Return the library path
      * @return the path (possibly null)
      */
      String getLibraryDirectoryPath();
  
  }
  
  
  
  1.1                  avalon-sandbox/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/JRMPKernelAdaptor.java
  
  Index: JRMPKernelAdaptor.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  
  package org.apache.avalon.merlin.kernel.impl;
  
  import javax.management.MBeanServer;
  import javax.management.ObjectName;
  import javax.naming.Context;
  
  import mx4j.adaptor.rmi.jrmp.JRMPAdaptor;
  import mx4j.tools.naming.NamingService;
  
  import org.apache.avalon.composition.util.ExceptionHelper;
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.logger.Logger;
  
  /**
   * RMIAdaptor for the JMX Server.
   *
   */
  public class JRMPKernelAdaptor extends AbstractLogEnabled implements Startable 
  {
      //--------------------------------------------------------------
      // immutable state
      //--------------------------------------------------------------
  
      private final int m_port;
      private final MBeanServer m_server;
      private final NamingService m_naming;
      private final JRMPAdaptor m_adapter = new JRMPAdaptor();
      private final ObjectName m_namingName;
      private final ObjectName m_name;
  
  
      //--------------------------------------------------------------
      // constructors
      //--------------------------------------------------------------
  
      public JRMPKernelAdaptor( Logger logger, MBeanServer server ) 
        throws Exception
      {
          this( logger, server, 1099 );
      }
  
      public JRMPKernelAdaptor( Logger logger, MBeanServer server, int port ) 
        throws Exception
      {
          super.enableLogging( logger );
  
          m_server = server;
          m_port = port;
  
          m_namingName = 
            new ObjectName( "JMXServer:name=naming,type=rmiregistry" );
          m_name = 
            new ObjectName( "JMXServer:name=adaptor,protocol=JRMP" );
  
          m_naming = new NamingService( m_port );
          m_server.registerMBean( m_naming, m_namingName );
  
          m_adapter.setJNDIName("jrmp");
          m_adapter.setPort( m_port );
          m_adapter.putJNDIProperty( 
            Context.INITIAL_CONTEXT_FACTORY, 
            "com.sun.jndi.rmi.registry.RegistryContextFactory" );
          m_adapter.putJNDIProperty(
            Context.PROVIDER_URL, 
            "rmi://localhost:" + m_port );
  
          m_server.registerMBean( m_adapter, m_name );
      }
  
      public void start() throws Exception 
      {
          //
          // Create and start the naming service
          //
  
          getLogger().info( "starting jmx" );
          getLogger().debug( "starting naming service" );
          m_naming.start();
  
          //
          // Optionally, you can specify the JNDI properties,
          // instead of having in the classpath a jndi.properties file
          //
  
          getLogger().debug( "starting jrmp adapter" );
          m_adapter.start();
      }
  
      public void stop() throws Exception 
      {
          getLogger().debug( "stopping jrmp adapter" );
          try
          {
              m_adapter.stop();
          }
          catch( Throwable e )
          {
              final String error = 
                "Ignoring error while attempting to stop adapter.";
              final String message = 
                ExceptionHelper.packException( error, e, true );
              getLogger().warn( message );
          }
  
          try
          {
              m_server.unregisterMBean( m_name );
          }
          catch( Throwable e )
          {
              final String error = 
                "Ignoring error while attempting to unregister adapter.";
              final String message = 
                ExceptionHelper.packException( error, e, true );
              getLogger().warn( message );
          }
  
          getLogger().debug( "stopping name service" );
          try
          {
              m_naming.stop();
          }
          catch( Throwable e )
          {
              final String error = 
                "Ignoring error while attempting to stop naming service.";
              final String message = 
                ExceptionHelper.packException( error, e, true );
              getLogger().warn( message );
          }
  
          try
          {
              m_server.unregisterMBean( m_namingName );
          }
          catch( Throwable e )
          {
              final String error = 
                "Ignoring error while attempting to unregister naming service.";
              final String message = 
                ExceptionHelper.packException( error, e, true );
              getLogger().warn( message );
          }
  
          getLogger().debug( "stopped" );
  
      }
  }
  
  
  
  1.3       +2 -10     avalon-sandbox/merlin/kernel/spi/src/java/org/apache/avalon/merlin/kernel/Kernel.java
  
  Index: Kernel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/kernel/spi/src/java/org/apache/avalon/merlin/kernel/Kernel.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Kernel.java	18 Aug 2003 11:26:06 -0000	1.2
  +++ Kernel.java	5 Sep 2003 09:59:27 -0000	1.3
  @@ -63,15 +63,7 @@
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  -public interface Kernel extends Home
  +public interface Kernel extends Home, Controller
   {
  -    //=======================================================================
  -    // static
  -    //=======================================================================
  -
  -   /**
  -    * Initiate an orderly shutdown of the kernel.
  -    */
  -    void shutdown();
   
   }
  
  
  
  1.5       +22 -3     avalon-sandbox/merlin/kernel/spi/src/java/org/apache/avalon/merlin/kernel/KernelContext.java
  
  Index: KernelContext.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/kernel/spi/src/java/org/apache/avalon/merlin/kernel/KernelContext.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- KernelContext.java	19 Aug 2003 05:45:15 -0000	1.4
  +++ KernelContext.java	5 Sep 2003 09:59:27 -0000	1.5
  @@ -11,6 +11,7 @@
   import org.apache.avalon.composition.data.TargetDirective;
   import org.apache.avalon.composition.logging.LoggingManager;
   import org.apache.avalon.composition.model.ModelFactory;
  +import org.apache.avalon.composition.model.ContainmentContext;
   import org.apache.excalibur.mpool.PoolManager;
   
   /**
  @@ -32,16 +33,34 @@
       Repository getRepository();
   
      /**
  +    * Return the runtime repository directory.
  +    * @return the repository path
  +    */
  +    File getRepositoryPath();
  +
  +   /**
       * Return the home path
       * @return the home path (possibly null)
       */
       File getHomePath();
   
      /**
  -    * Return the kernel configuration directive.
  -    * @return the kernel directive
  +    * Return the temporary directory path
  +    * @return the path (possibly null)
  +    */
  +    File getTempPath();
  +
  +   /**
  +    * Return the library path
  +    * @return the path (possibly null)
  +    */
  +    File getLibraryPath();
  +
  +   /**
  +    * Return the root containment context.
  +    * @return the kernel directive url
       */
  -    Configuration getKernelDirective();
  +    ContainmentContext getContainmentContext();
   
      /**
       * Return the URLs to install into the kerenel on startup.
  
  
  
  1.1                  avalon-sandbox/merlin/kernel/spi/src/java/org/apache/avalon/merlin/kernel/Controller.java
  
  Index: Controller.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.merlin.kernel;
  
  import java.net.URL;
  
  import org.apache.avalon.activation.appliance.Home;
  
  /**
   * A service that provides support for the establishment and management of a set
   * of component container.
   * <p><b>UML</b></p>
   * <p><image src="doc-files/kernel.gif" border="0"/></p>
   *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/09/05 09:59:27 $
   */
  public interface Controller
  {
      //=======================================================================
      // static
      //=======================================================================
  
     /**
      * Initiate the establishment of the root container.
      */
      void startup() throws Exception;
  
     /**
      * Initiate an orderly shutdown of the kernel.
      */
      void shutdown();
  
  }
  
  
  

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