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 2004/03/04 04:42:31 UTC

cvs commit: avalon/merlin/kernel/unit merlin.properties project.xml

mcconnell    2004/03/03 19:42:30

  Modified:    merlin/activation/impl/src/java/org/apache/avalon/activation/impl
                        AbstractAppliance.java
                        AbstractLifestyleManager.java
                        ApplianceInvocationHandler.java
                        DefaultAppliance.java DefaultLifestyleFactory.java
                        DefaultRuntimeFactory.java Resources.properties
                        SingletonLifestyleManager.java
                        ThreadLifestyleManager.java
                        TransientLifestyleManager.java
               merlin/activation/impl/src/test/org/apache/avalon/activation/impl/test
                        AbstractTestCase.java
               merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
                        DefaultSystemContext.java
                        DefaultSystemContextFactory.java
               merlin/composition/impl/src/test/org/apache/avalon/composition/model/test
                        AbstractTestCase.java
               merlin/composition/spi/src/java/org/apache/avalon/composition/provider
                        SystemContextFactory.java
               merlin/kernel/impl/conf kernel.xml
               merlin/kernel/unit merlin.properties project.xml
  Added:       merlin/activation/api/src/java/org/apache/avalon/activation
                        LifecycleRuntimeException.java
                        LifestyleException.java
                        RuntimeFactoryException.java
               merlin/composition/spi/src/java/org/apache/avalon/composition/provider
                        LifestyleFactory.java LifestyleManager.java
  Removed:     merlin/activation/api/src/java/org/apache/avalon/activation
                        LifestyleFactory.java LifestyleManager.java
  Log:
  Updates supporting the exposure of the LifestyleFactory and LifestyleManager and the integration of plugin support for a LifestyleFactory. These changes are a prereq for the integration of a lifestyle manager (i.e. JMX handler).
  
  Revision  Changes    Path
  1.1                  avalon/merlin/activation/api/src/java/org/apache/avalon/activation/LifecycleRuntimeException.java
  
  Index: LifecycleRuntimeException.java
  ===================================================================
  /* 
   * Copyright 2004 Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.avalon.activation;
  
  /**
   * Exception to indicate that there was a lifecycle runtime related error.
   *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2004/03/04 03:42:30 $
   */
  public class LifecycleRuntimeException
          extends ApplianceRuntimeException
  {
  
      /**
       * Construct a new <code>LifecycleRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public LifecycleRuntimeException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>LifecycleRuntimeException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public LifecycleRuntimeException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon/merlin/activation/api/src/java/org/apache/avalon/activation/LifestyleException.java
  
  Index: LifestyleException.java
  ===================================================================
  /* 
   * Copyright 2004 Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.avalon.activation;
  
  /**
   * Exception to indicate that there was an lifestyle related runtime error.
   *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2004/03/04 03:42:30 $
   */
  public final class LifestyleException
          extends ApplianceException
  {
  
      /**
       * Construct a new <code>LifestyleException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public LifestyleException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>LifestyleException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public LifestyleException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.1                  avalon/merlin/activation/api/src/java/org/apache/avalon/activation/RuntimeFactoryException.java
  
  Index: RuntimeFactoryException.java
  ===================================================================
  /* 
   * Copyright 2004 Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.avalon.activation;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * Exception to indicate that there was a error related to the runtime factory.
   *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2004/03/04 03:42:30 $
   */
  public class RuntimeFactoryException
          extends CascadingException
  {
  
      /**
       * Construct a new <code>RuntimeFactoryException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public RuntimeFactoryException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>RuntimeFactoryException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public RuntimeFactoryException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  
  1.2       +2 -1      avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/AbstractAppliance.java
  
  Index: AbstractAppliance.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/AbstractAppliance.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractAppliance.java	10 Feb 2004 16:19:15 -0000	1.1
  +++ AbstractAppliance.java	4 Mar 2004 03:42:30 -0000	1.2
  @@ -20,6 +20,7 @@
   import org.apache.avalon.activation.Appliance;
   
   import org.apache.avalon.composition.model.DeploymentModel;
  +import org.apache.avalon.composition.provider.LifestyleManager;
   
   import org.apache.avalon.framework.logger.Logger;
   
  
  
  
  1.4       +3 -2      avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/AbstractLifestyleManager.java
  
  Index: AbstractLifestyleManager.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/AbstractLifestyleManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractLifestyleManager.java	14 Feb 2004 21:33:55 -0000	1.3
  +++ AbstractLifestyleManager.java	4 Mar 2004 03:42:30 -0000	1.4
  @@ -23,12 +23,13 @@
   import java.lang.ref.ReferenceQueue;
   
   import org.apache.avalon.activation.LifecycleException;
  -import org.apache.avalon.activation.LifestyleManager;
   import org.apache.avalon.activation.ComponentFactory;
   
  +
   import org.apache.avalon.composition.model.ComponentModel;
   import org.apache.avalon.composition.model.DeploymentModel;
   import org.apache.avalon.composition.model.StageModel;
  +import org.apache.avalon.composition.provider.LifestyleManager;
   
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  
  
  
  1.6       +1 -2      avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/ApplianceInvocationHandler.java
  
  Index: ApplianceInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/ApplianceInvocationHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ApplianceInvocationHandler.java	29 Feb 2004 22:25:25 -0000	1.5
  +++ ApplianceInvocationHandler.java	4 Mar 2004 03:42:30 -0000	1.6
  @@ -28,7 +28,6 @@
   
   import org.apache.avalon.activation.Appliance;
   import org.apache.avalon.activation.ApplianceException;
  -import org.apache.avalon.activation.LifestyleManager;
   import org.apache.avalon.activation.TransientApplianceException;
   
   import org.apache.avalon.composition.model.ComponentModel;
  
  
  
  1.4       +2 -2      avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/DefaultAppliance.java
  
  Index: DefaultAppliance.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/DefaultAppliance.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultAppliance.java	29 Feb 2004 22:25:25 -0000	1.3
  +++ DefaultAppliance.java	4 Mar 2004 03:42:30 -0000	1.4
  @@ -21,10 +21,10 @@
   
   import org.apache.avalon.activation.ApplianceException;
   import org.apache.avalon.activation.TransientApplianceException;
  -import org.apache.avalon.activation.LifestyleManager;
   
   import org.apache.avalon.composition.model.ComponentModel;
   import org.apache.avalon.composition.model.TransientRuntimeException;
  +import org.apache.avalon.composition.provider.LifestyleManager;
   import org.apache.avalon.composition.util.DefaultState;
   
   import org.apache.avalon.excalibur.i18n.ResourceManager;
  
  
  
  1.3       +3 -3      avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/DefaultLifestyleFactory.java
  
  Index: DefaultLifestyleFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/DefaultLifestyleFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultLifestyleFactory.java	14 Feb 2004 21:33:55 -0000	1.2
  +++ DefaultLifestyleFactory.java	4 Mar 2004 03:42:30 -0000	1.3
  @@ -17,12 +17,12 @@
   
   package org.apache.avalon.activation.impl;
   
  -import org.apache.avalon.activation.LifestyleFactory;
  -import org.apache.avalon.activation.LifestyleManager;
   import org.apache.avalon.activation.ComponentFactory;
   
   import org.apache.avalon.composition.model.ComponentModel;
   import org.apache.avalon.composition.provider.SystemContext;
  +import org.apache.avalon.composition.provider.LifestyleFactory;
  +import org.apache.avalon.composition.provider.LifestyleManager;
   
   import org.apache.avalon.meta.info.InfoDescriptor;
   
  
  
  
  1.4       +138 -3    avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/DefaultRuntimeFactory.java
  
  Index: DefaultRuntimeFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/DefaultRuntimeFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultRuntimeFactory.java	29 Feb 2004 22:25:25 -0000	1.3
  +++ DefaultRuntimeFactory.java	4 Mar 2004 03:42:30 -0000	1.4
  @@ -19,10 +19,10 @@
   
   import java.util.Map;
   import java.util.Hashtable;
  +import java.lang.reflect.Constructor;
   
   import org.apache.avalon.activation.RuntimeFactory;
  -import org.apache.avalon.activation.LifestyleFactory;
  -import org.apache.avalon.activation.LifestyleManager;
  +import org.apache.avalon.activation.RuntimeFactoryException;
   import org.apache.avalon.activation.Appliance;
   import org.apache.avalon.activation.ApplianceException;
   import org.apache.avalon.activation.ApplianceRuntimeException;
  @@ -34,11 +34,15 @@
   import org.apache.avalon.composition.model.ComponentModel;
   import org.apache.avalon.composition.model.ContainmentModel;
   import org.apache.avalon.composition.provider.SystemContext;
  +import org.apache.avalon.composition.provider.LifestyleFactory;
  +import org.apache.avalon.composition.provider.LifestyleManager;
   
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   
   import org.apache.avalon.repository.Artifact;
  +import org.apache.avalon.repository.provider.InitialContext;
  +import org.apache.avalon.repository.provider.Builder;
   
   /**
    * A factory enabling the establishment of runtime handlers.
  @@ -78,6 +82,137 @@
           m_factory = new DefaultLifestyleFactory( m_system );
           m_secure = m_system.isCodeSecurityEnabled();
       }
  +
  +   /**
  +    * Get the runtime class referenced by the artifact.
  +    * @param context the repository initial context
  +    * @param artifact the factory artifact
  +    * @return the Runtime class
  +    */
  +    private LifestyleFactory getLifestyleFactory( 
  +      SystemContext system, InitialContext context, Artifact artifact )
  +      throws RuntimeFactoryException
  +    {
  +        if( null == artifact )
  +        {
  +            return new DefaultLifestyleFactory( system );
  +        }
  +
  +        try
  +        {
  +            ClassLoader classloader = 
  +              DefaultRuntimeFactory.class.getClassLoader();
  +            Builder builder = 
  +              context.newBuilder( classloader, artifact );
  +            Class candidate = builder.getFactoryClass();
  +            return buildLifestyleFactory( context, candidate );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              REZ.getString( "system.error.load", artifact.toString() );
  +            throw new RuntimeFactoryException( error, e );
  +        }
  +    }
  +
  +   /**
  +    * Build a lifestyle factory using a supplied class.
  +    *
  +    * @param clazz the log target factory class
  +    * @return a instance of the class
  +    * @exception RuntimeFactoryException if the class does not expose a public 
  +    *    constructor, or the constructor requires arguments that the 
  +    *    builder cannot resolve, or if a unexpected instantiation error 
  +    *    ooccurs
  +    */ 
  +    public LifestyleFactory buildLifestyleFactory( InitialContext context, Class clazz ) 
  +      throws RuntimeFactoryException
  +    {
  +        if( null == clazz )
  +        {
  +            throw new NullPointerException( "clazz" );
  +        }
  +
  +        Constructor[] constructors = clazz.getConstructors();
  +        if( constructors.length < 1 ) 
  +        {
  +            final String error = 
  +              REZ.getString( 
  +                "runtime.error.lifestyle.no-constructor", 
  +                clazz.getName() );
  +            throw new RuntimeFactoryException( error );
  +        }
  +
  +        //
  +        // lifestyle factories may declare constructor arguments
  +        // including the SystemContext, InitialContext, and/or 
  +        // RuntimeFactory
  +        //
  +
  +        Constructor constructor = constructors[0];
  +        Class[] classes = constructor.getParameterTypes();
  +        Object[] args = new Object[ classes.length ];
  +        for( int i=0; i<classes.length; i++ )
  +        {
  +            Class c = classes[i];
  +            if( SystemContext.class.isAssignableFrom( c ) )
  +            {
  +                args[i] = m_system;
  +            }
  +            else if( InitialContext.class.isAssignableFrom( c ) )
  +            {
  +                args[i] = context;
  +            }
  +            else if( RuntimeFactory.class.isAssignableFrom( c ) )
  +            {
  +                args[i] = this;
  +            }
  +            else
  +            {
  +                final String error = 
  +                  REZ.getString( 
  +                    "runtime.error.unrecognized-runtime-parameter", 
  +                    c.getName(),
  +                    clazz.getName() );
  +                throw new RuntimeFactoryException( error );
  +            }
  +        }
  +
  +        //
  +        // instantiate the factory
  +        //
  +
  +        return instantiateLifestyleFactory( constructor, args );
  +    }
  +
  +   /**
  +    * Instantiation of a lifestyle factory using a supplied constructor 
  +    * and arguments.
  +    * 
  +    * @param constructor the runtime constructor
  +    * @param args the constructor arguments
  +    * @return the runtime instance
  +    * @exception RuntimeFactoryException if an instantiation error occurs
  +    */
  +    private LifestyleFactory instantiateLifestyleFactory( 
  +      Constructor constructor, Object[] args ) 
  +      throws RuntimeFactoryException
  +    {
  +        Class clazz = constructor.getDeclaringClass();
  +        try
  +        {
  +            return (LifestyleFactory) constructor.newInstance( args );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              REZ.getString( 
  +                "runtime.error.lifestyle-instantiation", 
  +                clazz.getName() );
  +            throw new RuntimeFactoryException( error, e );
  +        }
  +    }
  +
   
       //-------------------------------------------------------------------
       // RuntimeFactory
  
  
  
  1.3       +3 -0      avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/Resources.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Resources.properties	12 Feb 2004 05:59:41 -0000	1.2
  +++ Resources.properties	4 Mar 2004 03:42:30 -0000	1.3
  @@ -3,6 +3,9 @@
   # DefaultRuntimeFactory
   # ---------------------
   runtime.error.unknown-model=Deployment model {0} class [{1}] is not supported.
  +runtime.error.lifestyle.no-constructor=The supplied lifestyle factory artifact references a class [{1}] that does not declare a public constructor.
  +runtime.error.unrecognized-runtime-parameter=LifestyleFactory constructor in [{0}] is requesting an unrecognized parameter [{1}].
  +runtime.error.runtime-instantiation=Cannot create lifestyle factory [{0}] due to an instantiation error.
   
   #
   # DefaultComponentFactory
  
  
  
  1.3       +2 -1      avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/SingletonLifestyleManager.java
  
  Index: SingletonLifestyleManager.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/SingletonLifestyleManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SingletonLifestyleManager.java	14 Feb 2004 21:33:55 -0000	1.2
  +++ SingletonLifestyleManager.java	4 Mar 2004 03:42:30 -0000	1.3
  @@ -22,6 +22,7 @@
   import org.apache.avalon.activation.ComponentFactory;
   
   import org.apache.avalon.composition.model.ComponentModel;
  +import org.apache.avalon.composition.provider.LifestyleManager;
   
   /**
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  
  
  
  1.3       +2 -1      avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/ThreadLifestyleManager.java
  
  Index: ThreadLifestyleManager.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/ThreadLifestyleManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ThreadLifestyleManager.java	14 Feb 2004 21:33:55 -0000	1.2
  +++ ThreadLifestyleManager.java	4 Mar 2004 03:42:30 -0000	1.3
  @@ -21,6 +21,7 @@
   import org.apache.avalon.activation.ComponentFactory;
   
   import org.apache.avalon.composition.model.ComponentModel;
  +import org.apache.avalon.composition.provider.LifestyleManager;
   
   /**
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  
  
  
  1.3       +2 -1      avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/TransientLifestyleManager.java
  
  Index: TransientLifestyleManager.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/impl/TransientLifestyleManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TransientLifestyleManager.java	14 Feb 2004 21:33:55 -0000	1.2
  +++ TransientLifestyleManager.java	4 Mar 2004 03:42:30 -0000	1.3
  @@ -25,6 +25,7 @@
   import org.apache.avalon.activation.ComponentFactory;
   
   import org.apache.avalon.composition.model.ComponentModel;
  +import org.apache.avalon.composition.provider.LifestyleManager;
   
   import org.apache.avalon.meta.info.InfoDescriptor;
   
  
  
  
  1.7       +5 -7      avalon/merlin/activation/impl/src/test/org/apache/avalon/activation/impl/test/AbstractTestCase.java
  
  Index: AbstractTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/activation/impl/src/test/org/apache/avalon/activation/impl/test/AbstractTestCase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractTestCase.java	1 Mar 2004 16:31:41 -0000	1.6
  +++ AbstractTestCase.java	4 Mar 2004 03:42:30 -0000	1.7
  @@ -203,14 +203,11 @@
         throws Exception
       {
           Artifact[] artifacts = getArtifactsToRegister( config );
  -        for( int i=0; i<artifacts.length; i++ )
  -        {
  -            Artifact artifact = artifacts[i];
  -            factory.addFactoryArtifact( artifact );
  -        }
  +        factory.setFactoryArtifacts( artifacts );
       }
   
  -    private static Artifact[] getArtifactsToRegister( Configuration config ) throws Exception
  +    private static Artifact[] getArtifactsToRegister( 
  +      Configuration config ) throws Exception
       {
           Configuration[] children = 
             config.getChildren( "artifact" );
  @@ -326,7 +323,8 @@
                   Env.getEnvVariable( "MAVEN_HOME_LOCAL" ) );
               if( null != local ) return local;
   
  -            return System.getProperty( "user.home" ) + File.separator + ".maven";
  +            return System.getProperty( "user.home" ) 
  +              + File.separator + ".maven";
   
           }
           catch( Throwable e )
  
  
  
  1.25      +36 -21    avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContext.java
  
  Index: DefaultSystemContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContext.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- DefaultSystemContext.java	1 Mar 2004 16:31:41 -0000	1.24
  +++ DefaultSystemContext.java	4 Mar 2004 03:42:30 -0000	1.25
  @@ -89,9 +89,9 @@
   
       private final Logger m_logger;
   
  -    private ModelFactory m_factory;
  +    private final ModelFactory m_factory;
   
  -    private Runtime m_runtime;
  +    private final Runtime m_runtime;
   
       private final long m_timeout;
   
  @@ -111,7 +111,9 @@
       * Creation of a new system context.
       *
       * @param context the repository intial context
  -    * @param artifact the runtime artifact
  +    * @param parent the parent context object (possibly null)
  +    * @param artifact an artifact reference to a plugin runtime factory
  +    * @param lifestyle an artifact reference to a plugin lifestyle factory
       * @param runtime the runtime class
       * @param logging the logging manager
       * @param base the base directory from which relative references 
  @@ -129,6 +131,7 @@
         InitialContext context, 
         Context parent, 
         Artifact artifact, 
  +      Artifact lifestyle, 
         Class runtime, 
         LoggingManager logging, 
         File base, 
  @@ -143,18 +146,15 @@
         TargetDirective[] targets ) throws SystemException
       {
           super( parent );
  -        if( base == null )
  -        {
  -            throw new NullPointerException( "base" );
  -        }
  -        if( repository == null )
  -        {
  -            throw new NullPointerException( "repository" );
  -        }
  -        if( logging == null )
  -        {
  -            throw new NullPointerException( "logging" );
  -        }
  +
  +        assertNotNull( "context", context );
  +        assertNotNull( "base", base );
  +        assertNotNull( "repository", repository );
  +        assertNotNull( "logging", logging );
  +        assertNotNull( "category", category );
  +        assertNotNull( "security", security );
  +        assertNotNull( "targets", targets );
  +
           if( !base.isDirectory() )
           {
               final String error = 
  @@ -192,12 +192,12 @@
   
           if( null != runtime )
           {
  -            m_runtime = buildRuntimeInstance( context, runtime );
  +            m_runtime = buildRuntimeInstance( context, runtime, lifestyle );
           }
           else if( null != artifact )
           {
               Class clazz = resolveRuntimeClass( context, artifact );
  -            m_runtime = buildRuntimeInstance( context, clazz );
  +            m_runtime = buildRuntimeInstance( context, clazz, lifestyle );
           }
           else
           {
  @@ -456,7 +456,7 @@
       private Artifact getDefaultRuntimeArtifact( InitialContext context )
       {
           Artifact[] artifacts = 
  -          context.getRegistry().getCandidates( Runtime.class );
  +          context.getRepository().getCandidates( Runtime.class );
           if( artifacts.length > 0 ) return artifacts[0];
   
           final String error =
  @@ -468,14 +468,17 @@
      /**
       * Build a runtime using a supplied class.
       *
  -    * @param clazz the log target factory class
  +    * @param context the initial context from which to bootstrap the runtime
  +    * @param clazz the runtime factory class
  +    * @param lifestyle the artifact referencing the lifestyle factory
       * @return a instance of the class
       * @exception SystemException if the class does not expose a public 
       *    constructor, or the constructor requires arguments that the 
       *    builder cannot resolve, or if a unexpected instantiation error 
       *    ooccurs
       */ 
  -    public Runtime buildRuntimeInstance( InitialContext context, Class clazz ) 
  +    public Runtime buildRuntimeInstance( 
  +      InitialContext context, Class clazz, Artifact lifestyle ) 
         throws SystemException
       {
           if( null == clazz ) return null;
  @@ -508,6 +511,10 @@
               {
                   args[i] = context;
               }
  +            else if( Artifact.class.isAssignableFrom( c ) )
  +            {
  +                args[i] = lifestyle;
  +            }
               else
               {
                   final String error = 
  @@ -552,5 +559,13 @@
                   clazz.getName() );
               throw new SystemException( error, e );
           }
  +    }
  +
  +    private void assertNotNull( String name, Object object )
  +    {
  +        if( null == object ) 
  +        {
  +            throw new NullPointerException( name );
  +        } 
       }
   }
  
  
  
  1.4       +20 -12    avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContextFactory.java
  
  Index: DefaultSystemContextFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContextFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultSystemContextFactory.java	1 Mar 2004 16:31:41 -0000	1.3
  +++ DefaultSystemContextFactory.java	4 Mar 2004 03:42:30 -0000	1.4
  @@ -102,6 +102,8 @@
   
       private Artifact m_artifact;
   
  +    private Artifact m_lifestyle;
  +
       private String m_name = "system";
   
       private SecurityProfile[] m_profiles;
  @@ -145,6 +147,11 @@
           m_artifact = artifact;
       }
   
  +    public void setLifestyleArtifact( Artifact artifact )
  +    {
  +        m_lifestyle = artifact;
  +    }
  +
       public void setRuntime( Class clazz )
       {
           m_runtime = clazz;
  @@ -222,6 +229,7 @@
             m_context, 
             getParentContext(), 
             getRuntimeArtifact(), 
  +          getLifestyleArtifact(), 
             getRuntimeClass(), 
             getLoggingManager(), 
             getBaseDirectory(), 
  @@ -259,6 +267,7 @@
   
       public TargetDirective[] getTargetDirectives()
       {
  +        if( null == m_targets ) return new TargetDirective[0];
           return m_targets;
       }
   
  @@ -352,16 +361,6 @@
       }
   
      /**
  -    * Return the system default grants directive.
  -    * @return the grants directive
  -    */
  -    public SecurityModel getSecurityModel()
  -    {
  -        if( null != m_security ) return m_security; 
  -        return new DefaultSecurityModel();
  -    }
  -
  -   /**
       * Return the class implementating the runtime.
       * @return the runtime class
       */
  @@ -380,6 +379,15 @@
       }
   
      /**
  +    * Return the artifact referencing the lifestyle factory.
  +    * @return the lifestyle factory artifact
  +    */
  +    public Artifact getLifestyleArtifact()
  +    {
  +        return m_lifestyle;
  +    }
  +
  +   /**
       * Utility method to create the LoggingManager.
       * @param criteria the kernel creation criteria
       * @param config the kernel configuration 
  @@ -388,7 +396,7 @@
       private LoggingManager createLoggingManager()
       {
           Artifact[] artifacts = 
  -          m_context.getRegistry().getCandidates( 
  +          m_context.getRepository().getCandidates( 
               LoggingManager.class );
           if( artifacts.length < 1 )
           {
  
  
  
  1.7       +23 -11    avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model/test/AbstractTestCase.java
  
  Index: AbstractTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model/test/AbstractTestCase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractTestCase.java	1 Mar 2004 16:31:41 -0000	1.6
  +++ AbstractTestCase.java	4 Mar 2004 03:42:30 -0000	1.7
  @@ -87,7 +87,7 @@
       public ContainmentModel setUp( String path ) throws Exception
       {
           //
  -        // grab the platform configuration
  +        // grab the system configuration
           //
   
           Configuration config = getConfiguration( SYS_CONF );
  @@ -102,30 +102,44 @@
           InitialContext context = setUpInitialContext( test, sysConfig );
   
           //
  -        // create a system context and add a test repository to use during 
  -        // testcase execution
  +        // create a system context factory and start profiling the 
  +        // system we want to run
           //
   
           SystemContextFactory factory = 
             new DefaultSystemContextFactory( context );
   
  +        //
  +        // setup the security profiles
  +        //
  +
           Configuration secConfig = config.getChild( "security" );
           SecurityProfile[] profiles = 
             SECURITY_BUILDER.createSecurityProfiles( secConfig );
           factory.setSecurityProfiles( profiles );
           factory.setSecurityEnabled( true );
   
  +        //
  +        // create a local application repository to use during test
  +        // execution
  +        //
  +
           Repository repository = 
             createTestRepository( context, new File( test, "repository" ) );
           factory.setRepository( repository );
   
  +        //
  +        // and create the system context and grab the model factory
  +        // so we can construct a model of the test deployment scenario
  +        //
  +
           SystemContext system = factory.createSystemContext();
  +        ModelFactory modelFactory = system.getModelFactory();
   
           //
           // create a containment model using the supplied path
           //
   
  -        ModelFactory modelFactory = system.getModelFactory();
           File confDir = new File( test, "conf" );
           File source = new File( confDir, path );
   
  @@ -153,18 +167,16 @@
           return initial.createInitialContext();
       }
   
  -    private void registerSystemArtifacts( InitialContextFactory factory, Configuration config )
  +    private void registerSystemArtifacts( 
  +      InitialContextFactory factory, Configuration config )
         throws Exception
       {
           Artifact[] artifacts = getArtifactsToRegister( config );
  -        for( int i=0; i<artifacts.length; i++ )
  -        {
  -            Artifact artifact = artifacts[i];
  -            factory.addFactoryArtifact( artifact );
  -        }
  +        factory.setFactoryArtifacts( artifacts );
       }
   
  -    private static Artifact[] getArtifactsToRegister( Configuration config ) throws Exception
  +    private static Artifact[] getArtifactsToRegister( 
  +      Configuration config ) throws Exception
       {
           Configuration[] children = 
             config.getChildren( "artifact" );
  
  
  
  1.4       +11 -2     avalon/merlin/composition/spi/src/java/org/apache/avalon/composition/provider/SystemContextFactory.java
  
  Index: SystemContextFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/spi/src/java/org/apache/avalon/composition/provider/SystemContextFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SystemContextFactory.java	1 Mar 2004 16:31:41 -0000	1.3
  +++ SystemContextFactory.java	4 Mar 2004 03:42:30 -0000	1.4
  @@ -60,6 +60,15 @@
       void setRuntime( Artifact artifact );
   
      /**
  +    * Set the lifestyle factory using a supplied artifact.
  +    * @param artifact a factory artifact supporting 
  +    *    {@link LifestyleFactory} instance creation. 
  +    * @see Runtime
  +    * @see #setRuntime( Class )
  +    */
  +    void setLifestyleArtifact( Artifact artifact );
  +
  +   /**
       * Set the runtime using a supplied class.
       * @param clazz a runtime implementation class 
       * @see Runtime
  @@ -110,7 +119,7 @@
   
      /**
       * Set the temporary directory.
  -    * @param work the temporary directory
  +    * @param temp the temporary directory
       */
       void setTemporaryDirectory( File temp );
   
  
  
  
  1.1                  avalon/merlin/composition/spi/src/java/org/apache/avalon/composition/provider/LifestyleFactory.java
  
  Index: LifestyleFactory.java
  ===================================================================
  /* 
   * Copyright 2004 Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.avalon.composition.provider;
  
  import org.apache.avalon.composition.model.ComponentModel;
  
  /**
   * A factory enabling the establishment of runtime handlers.
   *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2004/03/04 03:42:30 $
   */
  public interface LifestyleFactory
  {
     /**
      * Create a new lifestyle manager.
      * @param model the component model
      * @return the runtime appliance
      */
      LifestyleManager createLifestyleManager( ComponentModel model );
  }
  
  
  
  1.1                  avalon/merlin/composition/spi/src/java/org/apache/avalon/composition/provider/LifestyleManager.java
  
  Index: LifestyleManager.java
  ===================================================================
  /* 
   * Copyright 2004 Apache Software Foundation
   * Licensed  under the  Apache License,  Version 2.0  (the "License");
   * you may not use  this file  except in  compliance with the License.
   * You may obtain a copy of the License at 
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed  under the  License is distributed on an "AS IS" BASIS,
   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
   * implied.
   * 
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.avalon.composition.provider;
  
  import org.apache.avalon.composition.model.Commissionable;
  import org.apache.avalon.composition.model.Resolver;
  
  /**
   * A lifestyle handler provides support for a particular lifestyle policy.
   *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2004/03/04 03:42:30 $
   */
  public interface LifestyleManager extends Commissionable, Resolver
  {
      /**
       * Release and finalize the supplied object.
       *
       * @param instance the object to be released
       */
      void finalize( Object instance );
  
  }
  
  
  
  1.6       +33 -34    avalon/merlin/kernel/impl/conf/kernel.xml
  
  Index: kernel.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/impl/conf/kernel.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- kernel.xml	25 Feb 2004 20:31:01 -0000	1.5
  +++ kernel.xml	4 Mar 2004 03:42:30 -0000	1.6
  @@ -2,41 +2,40 @@
   
   <kernel>
   
  -   <logging>
  -     <categories priority="info" name="kernel">
  -       <category name="logger" priority="debug"/>
  -     </categories>
  -   </logging>
  +  <system>
  +    <artifact spec="avalon-logging/avalon-logkit-impl#1.0-SNAPSHOT"/>
  +  </system>
   
  -   <security>
  -     <certificates/>
  -     <permissions>
  -       <permission class="java.util.PropertyPermission" name="java.*">
  -         <action>read</action>
  -       </permission>
  -       <permission class="java.util.PropertyPermission" name="os.*">
  -         <action>read</action>
  -       </permission>
  -       <permission class="java.util.PropertyPermission" name="file.separator">
  -         <action>read</action>
  -       </permission>
  -       <permission class="java.util.PropertyPermission" name="path.separator">
  -         <action>read</action>
  -       </permission>
  -       <permission class="java.util.PropertyPermission" name="line.separator">
  -         <action>read</action>
  -       </permission>
  -       <permission class="java.util.PropertyPermission" name="user.name">
  -         <action>read</action>
  -       </permission>
  -     </permissions>
  -   </security>
  +  <security>
  +    <profile name="default">
  +      <permissions>
  +        <permission class="java.util.PropertyPermission" name="java.*">
  +          <action>read</action>
  +        </permission>
  +        <permission class="java.util.PropertyPermission" name="os.*">
  +          <action>read</action>
  +        </permission>
  +        <permission class="java.util.PropertyPermission" name="file.separator">
  +          <action>read</action>
  +        </permission>
  +        <permission class="java.util.PropertyPermission" name="path.separator">
  +          <action>read</action>
  +        </permission>
  +        <permission class="java.util.PropertyPermission" name="line.separator">
  +          <action>read</action>
  +        </permission>
  +        <permission class="java.util.PropertyPermission" name="user.name">
  +          <action>read</action>
  +        </permission>
  +      </permissions>
  +    </profile>
  +  </security>
   
  -   <repository>
  -     <hosts>
  -       <host path="http://dpml.net/"/>
  -       <host path="http://www.ibiblio.org/maven/"/>
  -     </hosts>
  -   </repository>
  +  <repository>
  +    <hosts>
  +      <host path="http://dpml.net/"/>
  +      <host path="http://www.ibiblio.org/maven/"/>
  +    </hosts>
  +  </repository>
   
   </kernel>
  
  
  
  1.6       +1 -1      avalon/merlin/kernel/unit/merlin.properties
  
  Index: merlin.properties
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/unit/merlin.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- merlin.properties	20 Feb 2004 22:49:56 -0000	1.5
  +++ merlin.properties	4 Mar 2004 03:42:30 -0000	1.6
  @@ -1,5 +1,5 @@
   
  -merlin.info = false
  +merlin.info = true
   merlin.debug = false
   merlin.deployment = conf/hello.block
   merlin.override = conf/override.xml
  
  
  
  1.27      +2 -3      avalon/merlin/kernel/unit/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/unit/project.xml,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- project.xml	4 Mar 2004 00:28:18 -0000	1.26
  +++ project.xml	4 Mar 2004 03:42:30 -0000	1.27
  @@ -33,14 +33,13 @@
       <unitTestSourceDirectory>${basedir}/src/test/</unitTestSourceDirectory>
   
       <unitTest>
  -      <!--
  +      <!-- -->
         <includes>
           <include>**/*Test.*</include>
           <include>**/*TestCase.*</include>
         </includes>
  -      -->
  +      <!-- -->
         <excludes>
  -        <exclude>**/*.*</exclude>
           <exclude>**/Abstract*.*</exclude>
         </excludes>
         <resources>
  
  
  

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