mcconnell    2002/12/20 21:17:22

  Modified:    assembly/src/java/org/apache/avalon/assembly/appliance
                        Appliance.java DefaultAppliance.java
                        DependencyGraph.java
               assembly/src/java/org/apache/avalon/assembly/engine
                        Engine.java EngineClassLoader.java
               assembly/src/java/org/apache/avalon/assembly/lifecycle
                        DefaultDeploymentService.java
               assembly/src/test/org/apache/avalon/assembly/engine
                        EngineTestCase.java
  Log:
  Rationalizing some of the services and getting them into appliance and out of 
the core engine.
  
  Revision  Changes    Path
  1.13      +13 -1     
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/Appliance.java
  
  Index: Appliance.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/Appliance.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Appliance.java    21 Dec 2002 03:46:46 -0000      1.12
  +++ Appliance.java    21 Dec 2002 05:17:22 -0000      1.13
  @@ -57,6 +57,7 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.assembly.lifestyle.LifestyleException;
  +import org.apache.avalon.assembly.lifecycle.AssemblyException;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.model.Profile;
  @@ -240,6 +241,17 @@
        * @return the set of extension provider appliances.
        */
       Appliance[] getExtensionProviders();
  +
  +   /**
  +    * Assemble the appliance.
  +    * @exception AssemblyException if an error occurs during appliance 
assembly
  +    */
  +    public void assemble() throws AssemblyException;
  +
  +   /**
  +    * Disassemble the appliance.
  +    */
  +    public void disassemble();
   
      /**
       * Creation of a instance of the component type managed by the appliance
  
  
  
  1.17      +39 -12    
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java
  
  Index: DefaultAppliance.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DefaultAppliance.java     21 Dec 2002 03:44:08 -0000      1.16
  +++ DefaultAppliance.java     21 Dec 2002 05:17:22 -0000      1.17
  @@ -71,9 +71,12 @@
   import org.apache.avalon.framework.service.ServiceException;
   
   import org.apache.avalon.assembly.engine.Engine;
  +import org.apache.avalon.assembly.engine.EngineClassLoader;
   import org.apache.avalon.assembly.lifestyle.LifestyleException;
   import org.apache.avalon.assembly.lifestyle.LifestyleService;
   import org.apache.avalon.assembly.lifestyle.LifestyleHandler;
  +import org.apache.avalon.assembly.lifecycle.AssemblyService;
  +import org.apache.avalon.assembly.lifecycle.AssemblyException;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.Type;
   import org.apache.avalon.meta.info.StageDescriptor;
  @@ -110,7 +113,12 @@
       /**
        * The lifestyle service from which the appliance lifestyle handler is 
established.
        */
  -    private Engine m_engine;
  +    private EngineClassLoader m_engine;
  +
  +    /**
  +     * The lifestyle service from which the appliance lifestyle handler is 
established.
  +     */
  +    private AssemblyService m_assembly;
   
       /**
        * The appliance context.
  @@ -169,11 +177,6 @@
       private Map m_deployment;
   
      /**
  -    * The activation policy.
  -    */
  -    private boolean m_activation;
  -
  -   /**
       * The appliance name.
       */
       private String m_name;
  @@ -183,7 +186,8 @@
       //==============================================================
   
       public DefaultAppliance( 
  -      Engine engine, ApplianceContext context, Context system, Logger logger 
)
  +      EngineClassLoader engine, LifestyleService lifestyle, AssemblyService 
assembly, 
  +      ApplianceContext context, Context system, Logger logger )
         throws ApplianceException
       {
           if( engine == null )
  @@ -194,6 +198,14 @@
           {
               throw new NullPointerException( "context" );
           }
  +        if( lifestyle == null )
  +        {
  +            throw new NullPointerException( "lifestyle" );
  +        }
  +        if( assembly == null )
  +        {
  +            throw new NullPointerException( "assembly" );
  +        }
           if( system == null )
           {
               throw new NullPointerException( "system" );
  @@ -203,11 +215,11 @@
               throw new NullPointerException( "logger" );
           }
   
  +        m_assembly = assembly;
           m_context = context;
           m_logger = logger;
           m_engine = engine;
           m_system = system;
  -        m_activation = context.getActivationPolicy();
   
           try
           {
  @@ -278,9 +290,7 @@
   
           try
           {
  -            m_handler = 
  -              m_engine.createLifestyleHandler( 
  -                this, system );
  +            m_handler = lifestyle.createHandler( this, engine, system );
           }
           catch( Throwable e )
           {
  @@ -418,7 +428,7 @@
        */
       public boolean getActivationPolicy()
       {
  -        return m_activation;
  +        return m_context.getActivationPolicy();
       }
   
       /**
  @@ -583,6 +593,23 @@
                 "Lifestyle handler raised a release error in appliance: " + 
this;
               throw new ApplianceRuntimeException( error, e );
           }
  +    }
  +
  +   /**
  +    * Assemble the appliance.
  +    * @exception AssemblyException if an error occurs during appliance 
assembly
  +    */
  +    public void assemble() throws AssemblyException
  +    {
  +        m_assembly.assemble( this );
  +    }
  +
  +   /**
  +    * Disassemble the appliance.
  +    */
  +    public void disassemble()
  +    {
  +        m_assembly.disassemble( this );
       }
   
       public String toString()
  
  
  
  1.5       +22 -1     
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DependencyGraph.java
  
  Index: DependencyGraph.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/appliance/DependencyGraph.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DependencyGraph.java      21 Dec 2002 03:28:37 -0000      1.4
  +++ DependencyGraph.java      21 Dec 2002 05:17:22 -0000      1.5
  @@ -315,6 +315,16 @@
                                    final ArrayList order )
       {
           //
  +        // get the context provider appliance
  +        //
  +
  +        Appliance contextProvider = appliance.getContextProvider();
  +        if( contextProvider != null )
  +        {
  +            visitcomponent( contextProvider, true, done, order );
  +        }
  +
  +        //
           // get all of the extensions the provide extension
           // support to the subject appliance
           //
  @@ -393,6 +403,17 @@
                   {
                       visitcomponent( other, false, done, order );
                   }
  +            }
  +
  +            //
  +            // check if the 'other' appliance is used by this 'appliance'
  +            // as a context provider
  +            //
  +
  +            final Appliance contextProvider = other.getContextProvider();
  +            if( ( contextProvider != null ) && contextProvider.equals( 
appliance ) )
  +            {
  +                visitcomponent( other, false, done, order );
               }
   
               //
  
  
  
  1.10      +2 -10     
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/Engine.java
  
  Index: Engine.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/Engine.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Engine.java       19 Dec 2002 10:37:26 -0000      1.9
  +++ Engine.java       21 Dec 2002 05:17:22 -0000      1.10
  @@ -73,16 +73,9 @@
    * @author <a href="mailto:avalon-dev@jakarta.apache.org";>Avalon Development 
Team</a>
    * @version $Revision$ $Date$
    */
  -public interface Engine extends AssemblyService
  +public interface Engine 
   {
      /**
  -    * Creation of a new lifestyle handler.
  -    * @param appliance the appliance that the handler will manage
  -    * @param context the system context
  -    */
  -    LifestyleHandler createLifestyleHandler( Appliance appliance, Context 
context );
  -
  -   /**
       * Dynamic registration of a type and associated profiles with the 
container.
       * @param path the path to the appliance implementation class
       * @return the appliance
  @@ -106,7 +99,6 @@
       * @return the appliance
       */
       Appliance resolve( DependencyDescriptor dependency ) throws Exception;
  -
   
      /**
       * Resolve an appliance capable of supporting a service 
  
  
  
  1.15      +20 -45    
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java
  
  Index: EngineClassLoader.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- EngineClassLoader.java    21 Dec 2002 03:28:37 -0000      1.14
  +++ EngineClassLoader.java    21 Dec 2002 05:17:22 -0000      1.15
  @@ -765,28 +765,6 @@
       }
   
       //==============================================================
  -    // AssemblyService
  -    //==============================================================
  -
  -   /**
  -    * Assemble the supplied appliance.
  -    * @param appliance the object to assembly
  -    */
  -    public void assemble( Appliance appliance ) throws AssemblyException
  -    {
  -        m_assembly.assemble( appliance );
  -    }
  -
  -   /**
  -    * Disassemble the supplied appliance.
  -    * @param appliance the object to disassembly
  -    */
  -    public void disassemble( Appliance appliance )
  -    {
  -        m_assembly.disassemble( appliance );
  -    }
  -
  -    //==============================================================
       // Engine
       //==============================================================
   
  @@ -800,17 +778,6 @@
       }
   
      /**
  -    * Creation of a new lifestyle handler.
  -    * @param appliance the appliance that the handler will manage
  -    * @param context the system context
  -    * @param map supplimentary deployment context
  -    */
  -    public LifestyleHandler createLifestyleHandler( Appliance appliance, 
Context context )
  -    {
  -        return m_lifestyle.createHandler( appliance, this, context );
  -    }
  -
  -   /**
       * Register a type and associated profiles with the container.
       * @param path the path to the appliance implementation class
       * @return the appliance
  @@ -885,7 +852,7 @@
                   context.setPartitionName( partition );
                   context.makeReadOnly();
                   appliance = createAppliance( context, true );
  -                assemble( appliance );
  +                appliance.assemble();
               }
           }
           return appliance;
  @@ -938,7 +905,7 @@
                   context.setPartitionName( partition );
                   context.makeReadOnly();
                   appliance = createAppliance( context, true );
  -                assemble( appliance );
  +                appliance.assemble();
               }
           }
           return appliance;
  @@ -1010,8 +977,20 @@
               try
               {
                   Constructor constructor = clazz.getConstructor(
  -                    new Class[]{ Engine.class, ApplianceContext.class, 
Context.class, Logger.class } );
  -                Object[] args = new Object[]{ this, context, system, logger 
};
  +                    new Class[]{ 
  +                        EngineClassLoader.class, 
  +                        LifestyleService.class, 
  +                        AssemblyService.class, 
  +                        ApplianceContext.class, 
  +                        Context.class, 
  +                        Logger.class } );
  +                Object[] args = new Object[]{ 
  +                        this, 
  +                        m_lifestyle, 
  +                        m_assembly, 
  +                        context, 
  +                        system, 
  +                        logger };
                   return (Appliance) constructor.newInstance( args );
               }
               catch( NoSuchMethodException nsme )
  @@ -1021,6 +1000,8 @@
                       + classname 
                       + "' does not implement a constructor matching the 
pattern: ( "
                       + Engine.class.getName()
  +                    + ", " + LifestyleService.class.getName()
  +                    + ", " + AssemblyService.class.getName()
                       + ", " + ApplianceContext.class.getName()
                       + ", " + Context.class.getName()
                       + ", " + Logger.class.getName()
  @@ -1043,7 +1024,7 @@
           }
           else
           {
  -            return new DefaultAppliance( this, context, system, logger );
  +            return new DefaultAppliance( this, m_lifestyle, m_assembly, 
context, system, logger );
           }
       }
   
  @@ -1120,11 +1101,6 @@
       private DeploymentService bootstrapDeploymentService( Map facilities ) 
         throws ServiceException
       {
  -        if( m_assembly == null )
  -        {
  -            throw new IllegalStateException( "assembly" );
  -        }
  -
           try
           {
               DefaultDeploymentService deployment = new 
DefaultDeploymentService();
  @@ -1132,7 +1108,6 @@
               MappedServiceManager manager = new MappedServiceManager( 
facilities );
               manager.put("urn:assembly:logging.manager", m_logging );
               manager.put("urn:assembly:engine.classloader", this );
  -            manager.put("urn:assembly:engine.assembly", m_assembly );
               deployment.service( manager );
               deployment.contextualize( new DefaultContext() );
               deployment.initialize();
  
  
  
  1.10      +3 -7      
avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultDeploymentService.java
  
  Index: DefaultDeploymentService.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/DefaultDeploymentService.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultDeploymentService.java     20 Dec 2002 11:54:28 -0000      1.9
  +++ DefaultDeploymentService.java     21 Dec 2002 05:17:22 -0000      1.10
  @@ -102,8 +102,6 @@
   
       private Context m_context;
       private ServiceManager m_manager;
  -    private AssemblyService m_assembly;
  -
       private LoggingService m_logging;
       private ConfigurationService m_configuration;
       private ContextualizationService m_contextualization;
  @@ -178,8 +176,6 @@
               throw new NullPointerException( "manager" );
           }
   
  -        m_assembly = (AssemblyService) manager.lookup( 
"urn:assembly:engine.assembly" );
  -
           final String classloaderkey = "urn:assembly:engine.classloader";
           if( !manager.hasService( classloaderkey ) )
           {
  @@ -328,7 +324,7 @@
   
           try
           {
  -            m_assembly.assemble( appliance );
  +            appliance.assemble();
           }
           catch( Throwable e )
           {
  @@ -403,7 +399,7 @@
   
           if( disassemble )
           {
  -            m_assembly.disassemble( appliance );
  +            appliance.disassemble();
           }
   
           try
  
  
  
  1.10      +1 -1      
avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java
  
  Index: EngineTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/assembly/src/test/org/apache/avalon/assembly/engine/EngineTestCase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- EngineTestCase.java       21 Dec 2002 03:28:38 -0000      1.9
  +++ EngineTestCase.java       21 Dec 2002 05:17:22 -0000      1.10
  @@ -215,7 +215,7 @@
               DefaultApplianceContext context = new DefaultApplianceContext( 
profile );
               context.makeReadOnly();
               Appliance appliance = m_engine.createAppliance( context, false );
  -            m_engine.assemble( appliance );
  +            appliance.assemble();
               assertTrue( appliance.access() != null );
           }
           catch( Throwable e )
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to