avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl DefaultBlockLoader.java
Date Sun, 13 Apr 2003 12:13:51 GMT
mcconnell    2003/04/13 05:13:50

  Modified:    merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl
                        DefaultBlockLoader.java
  Log:
  Corrected missing method (lost during refactoring).
  
  Revision  Changes    Path
  1.10      +128 -1    avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/DefaultBlockLoader.java
  
  Index: DefaultBlockLoader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/DefaultBlockLoader.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultBlockLoader.java	13 Apr 2003 05:45:09 -0000	1.9
  +++ DefaultBlockLoader.java	13 Apr 2003 12:13:50 -0000	1.10
  @@ -587,6 +587,133 @@
       }
   
      /**
  +    * Load a block declared in the supplied block and configuration URL.
  +    * The path URL may refer to a XML file containing a block directive
  +    * or a jar file containing a block.xml file. 
  +    *
  +    * @param path the block defintion URL
  +    * @param overrides the URL to a configuration containing configuration overrides
  +    * @return the block
  +    */
  +    private Block installSource( EngineClassLoader loader, String root, URL path, URL overrides
)
  +      throws BlockException
  +    {
  +
  +        Configuration block = getSourceConfiguration( path );
  +        Configuration config = getTargetsConfiguration( overrides );
  +        String name = getBlockName( block );
  +
  +        Configuration[] targets = config.getChildren( "target" );
  +
  +        if( getLogger().isDebugEnabled() )
  +        {
  +            getLogger().debug("target override count: " + targets.length );
  +        }
  +
  +        for( int j=0; j<targets.length; j++ )
  +        {
  +            Configuration target = targets[j];
  +            try
  +            {
  +                String key = root + name + "/" + target.getAttribute( "name" );
  +                m_library.put( key, target.getChild( "configuration" ) );
  +                getLogger().debug( "registering configuration for key: " + key );
  +            }
  +            catch( Throwable e )
  +            {
  +                final String error =
  +                  "A configuration target override does not declare a target." 
  +                  + "\nURL: " + overrides
  +                  + ConfigurationUtil.list( target );
  +                throw new BlockException( error, e );
  +            }
  +        }
  +
  +        URL base = getBasePath( path );
  +        Configuration implementation = block.getChild( "implementation", false );
  +        if( implementation == null )
  +        {
  +            implementation = block.getChild( "container" );
  +        }
  +        Configuration engineConfig = implementation.getChild( "engine" );
  +        EngineClassLoader engine = null;
  +        try
  +        {
  +            engine = createEngine( loader, m_home, engineConfig, name, base, base );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Could not construct engine for block: " + name;
  +            throw new BlockException( error, e );
  +        }
  +
  +        //
  +        // create the containment profile
  +        //
  +
  +        ContainmentProfile descriptor = 
  +          createContainmentProfile( name, engine, implementation );
  +
  +        //
  +        // create the block dependencies
  +        //
  +
  +        Configuration depsConfig = block.getChild( "dependencies", false );
  +        DependencyDescriptor[] dependencies = null; 
  +        if( depsConfig != null )
  +        {
  +            try
  +            {
  +                dependencies = TYPE_CREATOR.buildDependencies( depsConfig );
  +            }
  +            catch( ConfigurationException ce )
  +            {
  +                final String error = 
  +                  "Invalid dependencies declaration in block specification:\n"
  +                  + ConfigurationUtil.list( depsConfig );
  +                throw new BlockException( error, ce );
  +            }
  +        }
  +        
  +        //
  +        // create the block services
  +        //
  +
  +        Configuration servicesConfig = block.getChild( "dependencies" , false );
  +        ServiceDescriptor[] services = null;
  +        if( servicesConfig != null )
  +        {
  +            try
  +            {
  +                services = TYPE_CREATOR.buildServices( servicesConfig );
  +            }
  +            catch( ConfigurationException ce )
  +            {
  +                final String error = 
  +                  "Invalid services declaration in block specification:\n"
  +                  + ConfigurationUtil.list( depsConfig );
  +                throw new BlockException( error, ce );
  +            }
  +        }
  +
  +        //
  +        // create any subsidiary blocks
  +        //
  +
  +        String partition = root + name + Container.PATH_SEPERATOR;
  +        List children = 
  +          createChildBlocks( engine, partition, implementation, config, base );
  +
  +        //
  +        // create the block 
  +        //
  +
  +        return createBlock( 
  +          dependencies, services, engine, children, descriptor, name, root, config );
  +    }
  +
  +   /**
       * Create a single containment block.
       *
       * @param engine the containers classloader
  
  
  

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


Mime
View raw message