mcconnell    2003/10/12 10:12:45

  Modified:    merlin/composition/api/src/java/org/apache/avalon/composition/model
                        ContainmentModel.java
               
merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
                        DefaultContainmentModel.java
               merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl
                        DefaultKernel.java DefaultKernelContext.java
               merlin/kernel/spi project.xml
               merlin/kernel/spi/src/java/org/apache/avalon/merlin/kernel
                        Kernel.java
               merlin/platform/xdocs/starting/tutorial/context entries.xml
  Log:
  Housekeeping  / tweeking.
  
  Revision  Changes    Path
  1.2       +13 -1     
avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentModel.java
  
  Index: ContainmentModel.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContainmentModel.java     24 Sep 2003 09:31:15 -0000      1.1
  +++ ContainmentModel.java     12 Oct 2003 17:12:45 -0000      1.2
  @@ -138,6 +138,18 @@
       Model addModel( URL url ) throws ModelException;
   
      /**
  +    * Addition of a new subsidiary containment model within
  +    * the containment context using a supplied url.
  +    *
  +    * @param url a url referencing a containment profile
  +    * @param url containment configuration targets
  +    * @return the model created using the derived profile and configuration
  +    * @exception ModelException if an error occurs during model establishment
  +    */
  +    public ContainmentModel addContainmentModel( URL block, URL config ) 
  +      throws ModelException;
  +
  +   /**
       * Addition of a new subsidiary model within
       * the containment context using a supplied profile.
       *
  
  
  
  1.4       +87 -5     
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
  
  Index: DefaultContainmentModel.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultContainmentModel.java      7 Oct 2003 17:41:36 -0000       1.3
  +++ DefaultContainmentModel.java      12 Oct 2003 17:12:45 -0000      1.4
  @@ -72,6 +72,7 @@
   import org.apache.avalon.composition.data.ResourceDirective;
   import org.apache.avalon.composition.data.ServiceDirective;
   import org.apache.avalon.composition.data.TargetDirective;
  +import org.apache.avalon.composition.data.builder.XMLTargetsCreator;
   import org.apache.avalon.composition.data.builder.ContainmentProfileBuilder;
   import org.apache.avalon.composition.data.builder.XMLContainmentProfileCreator;
   import org.apache.avalon.composition.model.ClassLoaderContext;
  @@ -111,9 +112,9 @@
   public class DefaultContainmentModel extends DefaultModel 
     implements ContainmentModel
   {
  -    //==============================================================
  +    //--------------------------------------------------------------
       // static
  -    //==============================================================
  +    //--------------------------------------------------------------
   
       private static final Resources REZ =
               ResourceManager.getPackageResources( DefaultContainmentModel.class );
  @@ -124,6 +125,9 @@
       private static final XMLContainmentProfileCreator CREATOR = 
         new XMLContainmentProfileCreator();
   
  +    private static final XMLTargetsCreator TARGETS = 
  +      new XMLTargetsCreator();
  +
       private static String getPath( ContainmentContext context )
       {
           if( context.getPartitionName() == null )
  @@ -271,8 +275,16 @@
   
       public Model addModel( URL url ) throws ModelException
       {
  -        ContainmentModel model = createContainmentModel( null, url );
  -        return addModel( model.getName(), model );
  +        return addContainmentModel( url, null );
  +    }
  +
  +    public ContainmentModel addContainmentModel( URL block, URL config ) 
  +      throws ModelException
  +    {
  +        ContainmentModel model = createContainmentModel( null, block );
  +        addModel( model.getName(), model );
  +        applyTargets( config );
  +        return model;
       }
   
       public Model addModel( Profile profile ) throws ModelException
  @@ -328,6 +340,7 @@
           return model;
       }
   
  +
      /**
       * Creation of a new instance of a deployment model within
       * this containment context.
  @@ -1022,5 +1035,74 @@
                   profile.getClassname() );
               throw new ModelException( error, e );
           }
  +    }
  +
  +    private void applyTargets( URL config )
  +      throws ModelException
  +    {
  +        if( config != null )
  +        {
  +            TargetDirective[] targets = getTargets( config );
  +            applyTargets( targets );
  +        }
  +    }
  +
  +    private void applyTargets( TargetDirective[]targets )
  +    {
  +        for( int i=0; i<targets.length; i++ )
  +        {
  +            TargetDirective target = targets[i];
  +            final String path = target.getPath();
  +            Object model = getModel( path );
  +            if( model != null )
  +            {
  +                if( model instanceof DeploymentModel )
  +                {
  +                    DeploymentModel deployment = (DeploymentModel) model;
  +                    if( target.getConfiguration() != null )
  +                    {
  +                        deployment.setConfiguration( target.getConfiguration() );
  +                    }
  +                    if( target.getCategoriesDirective() != null )
  +                    {
  +                        deployment.setCategories( target.getCategoriesDirective() );
  +                    }
  +                }
  +                else if( model instanceof ContainmentModel )
  +                {
  +                    ContainmentModel containment = (ContainmentModel) model;
  +                    if( target.getCategoriesDirective() != null )
  +                    {
  +                        containment.setCategories( target.getCategoriesDirective() 
);
  +                    }
  +                }
  +            }
  +            else
  +            {
  +                final String warning = 
  +                  "Ignoring target directive as the path does not refer to a known 
component: " 
  +                  + path;
  +                getLogger().warn( warning );
  +            }
  +        }
  +    }
  +
  +    private TargetDirective[] getTargets( final URL url )
  +      throws ModelException
  +    {
  +        try
  +        {
  +            DefaultConfigurationBuilder builder = 
  +              new DefaultConfigurationBuilder();
  +            Configuration config = builder.build( url.toString() );
  +            return TARGETS.createTargets( config ).getTargets();
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Could not load the targets directive: " + url;
  +            throw new ModelException( error, e );
  +        }
  +        
       }
   }
  
  
  
  1.3       +11 -1     
avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernel.java
  
  Index: DefaultKernel.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernel.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultKernel.java        7 Oct 2003 17:44:09 -0000       1.2
  +++ DefaultKernel.java        12 Oct 2003 17:12:45 -0000      1.3
  @@ -413,6 +413,16 @@
           }
       }
   
  +   /**
  +    * Return the root block.
  +    * @return the containment block
  +    */
  +    public Block getRootBlock()
  +    {
  +        if( m_block == null ) throw new IllegalStateException( "not-started" );
  +        return m_block;
  +    }
  +
       //--------------------------------------------------------------
       // DefaultKernel
       //--------------------------------------------------------------
  
  
  
  1.3       +3 -3      
avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernelContext.java
  
  Index: DefaultKernelContext.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/merlin/kernel/impl/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernelContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultKernelContext.java 7 Oct 2003 17:44:10 -0000       1.2
  +++ DefaultKernelContext.java 12 Oct 2003 17:12:45 -0000      1.3
  @@ -127,9 +127,9 @@
       private static final String USER_DIR = 
         System.getProperty( "user.dir" ).replace( '\\', '/' );
   
  -    //==============================================================
  +    //--------------------------------------------------------------
       // immutable state
  -    //==============================================================
  +    //--------------------------------------------------------------
   
       /**
        * The system repository.
  
  
  
  1.3       +0 -16     avalon/merlin/kernel/spi/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/spi/project.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- project.xml       7 Oct 2003 17:44:10 -0000       1.2
  +++ project.xml       12 Oct 2003 17:12:45 -0000      1.3
  @@ -19,12 +19,6 @@
     <dependencies>
       
       <dependency>
  -      <groupId>avalon-repository</groupId>
  -      <artifactId>avalon-repository-spi</artifactId>
  -      <version>1.0b1</version>
  -    </dependency>
  -
  -    <dependency>
         <groupId>avalon-framework</groupId>
         <artifactId>avalon-framework-api</artifactId>
         <version>4.1.5</version>
  @@ -40,16 +34,6 @@
         <groupId>avalon-activation</groupId>
         <artifactId>avalon-activation-api</artifactId>
         <version>1.0b1</version>
  -    </dependency>
  -    <dependency>
  -      <groupId>avalon-activation</groupId>
  -      <artifactId>avalon-activation-spi</artifactId>
  -      <version>1.0b1</version>
  -    </dependency>
  -
  -    <dependency>
  -      <id>excalibur-event</id>
  -      <version>1.0.3</version>
       </dependency>
   
     </dependencies>
  
  
  
  1.3       +7 -1      
avalon/merlin/kernel/spi/src/java/org/apache/avalon/merlin/kernel/Kernel.java
  
  Index: Kernel.java
  ===================================================================
  RCS file: 
/home/cvs/avalon/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       7 Oct 2003 17:44:10 -0000       1.2
  +++ Kernel.java       12 Oct 2003 17:12:45 -0000      1.3
  @@ -75,4 +75,10 @@
       */
       Block getBlock( ContainmentModel model ) throws KernelException;
   
  +   /**
  +    * Return the root block.
  +    * @return the containment block
  +    */
  +    Block getRootBlock();
  +
   }
  
  
  
  1.5       +5 -2      
avalon/merlin/platform/xdocs/starting/tutorial/context/entries.xml
  
  Index: entries.xml
  ===================================================================
  RCS file: 
/home/cvs/avalon/merlin/platform/xdocs/starting/tutorial/context/entries.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- entries.xml       1 Oct 2003 11:06:09 -0000       1.4
  +++ entries.xml       12 Oct 2003 17:12:45 -0000      1.5
  @@ -129,7 +129,8 @@
           <p><i>HelloComponent.xinfo</i></p>
   <source><![CDATA[
   <?xml version="1.0" encoding="ISO-8859-1"?>
  -<!DOCTYPE type PUBLIC "-//AVALON/Type DTD Version 1.0//EN" 
"http://avalon.apache.org/dtds/meta/type_1_1.dtd"; >
  +<!DOCTYPE type PUBLIC "-//AVALON/Type DTD Version 1.0//EN" 
  +  "http://avalon.apache.org/dtds/meta/type_1_1.dtd"; >
   
   <type>
     <info>
  @@ -202,7 +203,9 @@
      <classloader>
        <classpath>
          <repository>
  -         <resource id="avalon-framework:avalon-framework-impl" version="4.1.5"/>
  +         <resource 
  +           id="avalon-framework:avalon-framework-impl" 
  +           version="4.1.5"/>
          </repository>
        </classpath>
      </classloader>
  
  
  

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

Reply via email to