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/04/06 21:24:52 UTC

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

mcconnell    2003/04/06 12:24:52

  Modified:    merlin/assembly/src/java/org/apache/avalon/assembly/appliance
                        ApplianceURLConnection.java DefaultAppliance.java
                        DefaultApplianceRepository.java
               merlin/assembly/src/java/org/apache/avalon/assembly/engine
                        EngineClassLoader.java
               merlin/assembly-spi/src/java/org/apache/avalon/assembly/appliance
                        ApplianceRepository.java
               merlin/assembly-spi/src/java/org/apache/avalon/assembly/engine
                        Engine.java
               merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl
                        DefaultBlockLoader.java
               merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl
                        DefaultKernel.java DefaultKernel.xinfo
               merlin/merlin-spi/src/java/org/apache/avalon/merlin/kernel
                        Kernel.java
  Log:
  Addition of support for appliance access via URL.
  
  Revision  Changes    Path
  1.2       +7 -5      avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceURLConnection.java
  
  Index: ApplianceURLConnection.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceURLConnection.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ApplianceURLConnection.java	13 Mar 2003 01:03:39 -0000	1.1
  +++ ApplianceURLConnection.java	6 Apr 2003 19:24:51 -0000	1.2
  @@ -82,11 +82,15 @@
       /**
        * Creation of a new <code>ApplianceURLConnection</code> handler.
        * @param url the base URL
  -     * @param registry the parent registry
  +     * @param repository the root appliance repository
        */
       public ApplianceURLConnection( URL url, ApplianceRepository repository )
       {
           super( url );
  +        if( repository == null )
  +        {
  +            throw new NullPointerException( "repository" );
  +        }
           m_repository = repository;
           m_url = url;
       }
  @@ -110,8 +114,7 @@
        */
       public Object getContent() throws IOException
       {
  -        System.out.println( "CONNECTION: " + m_url + " from repository: " + m_repository.getURL() );
  -        return m_url;
  +        return getContent( new Class[0] );
       }
   
       /**
  @@ -129,7 +132,6 @@
        */
       public Object getContent( Class[] classes ) throws IOException
       {
  -        System.out.println( "CONNECTION[]: " + m_url + " from repository: " + m_repository.getURL() );
  -        return m_url;
  +        return m_repository.resolve( m_url.getPath() );
       }
   }
  
  
  
  1.6       +21 -1     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java
  
  Index: DefaultAppliance.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultAppliance.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultAppliance.java	3 Apr 2003 22:14:06 -0000	1.5
  +++ DefaultAppliance.java	6 Apr 2003 19:24:51 -0000	1.6
  @@ -432,6 +432,26 @@
       }
   
      /**
  +    * Get the URL for a service.
  +    * @param reference the service reference descriptor
  +    * @return the service URL
  +    */
  +    public URL getURL( ReferenceDescriptor reference ) throws UnknownServiceException
  +    {
  +        try
  +        {
  +            final URL url = getURL();
  +            return new URL( url, url.getPath() + "?service=" + reference.toString() );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error =
  +              "Unexpected error while creating a URL for service: " + reference;
  +            throw new ApplianceRuntimeException( error, e );
  +        }
  +    }
  +
  +   /**
       * Get the appliance partition name.
       */
       public String getPartitionName()
  
  
  
  1.2       +142 -40   avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceRepository.java
  
  Index: DefaultApplianceRepository.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceRepository.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultApplianceRepository.java	13 Mar 2003 01:03:45 -0000	1.1
  +++ DefaultApplianceRepository.java	6 Apr 2003 19:24:51 -0000	1.2
  @@ -71,6 +71,7 @@
    * @todo the engine constructor argument is not being used and should be retracted
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    * @version $Revision$ $Date$
  + * @todo add custom appliance selector support
    */
   public final class DefaultApplianceRepository 
     implements ApplianceRepository
  @@ -88,7 +89,12 @@
       /**
        * Table of registered appliance instances keyed by profile name.
        */
  -    private final ArrayList m_appliances = new ArrayList();
  +    private final Map m_appliances = new Hashtable();
  +
  +    /**
  +     * Table of subsidary repositories.
  +     */
  +    private final Map m_children = new Hashtable();
           
      /**
       * The engine.
  @@ -111,48 +117,45 @@
   
       public DefaultApplianceRepository( Engine engine )
       {
  -        this( engine, null, null );
  +        m_engine = engine;
  +        m_name = "/";
  +        try
  +        {
  +            m_url = new URL( 
  +              "appliance", "localhost", -1, m_name, new ApplianceHandler( this ) );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error =
  +              "Unexpected error while creating the root repository URL.";
  +            throw new ApplianceRuntimeException( error, e );
  +        }
       }
   
  -    public DefaultApplianceRepository( Engine engine, ApplianceRepository parent, String name )
  +    private DefaultApplianceRepository( Engine engine, ApplianceRepository parent, String name )
       {
           m_parent = parent;
           m_engine = engine;
           m_name = name;
  -        if( parent == null )
  +
  +        final URL url = parent.getURL();
  +        try
           {
  -            try
  +            if( name.endsWith("/") )
               {
  -                m_url = new URL( "appliance", "localhost", -1, "/", new Handler( parent ) );
  +                m_url = new URL( url, url.getPath() + name );
               }
  -            catch( Throwable e )
  +            else
               {
  -                final String error =
  -                  "Unexpected error while creating a root URL for repository: " + name;
  -                throw new ApplianceRuntimeException( error, e );
  +                m_url = new URL( url, url.getPath() + name + "/" );
               }
           }
  -        else
  +        catch( Throwable e )
           {
  -            final URL url = parent.getURL();
  -            try
  -            {
  -                if( name.endsWith("/") )
  -                {
  -                    m_url = new URL( url, url.getPath() + name );
  -                }
  -                else
  -                {
  -                    m_url = new URL( url, url.getPath() + name + "/" );
  -                }
  -            }
  -            catch( Throwable e )
  -            {
  -                final String error = 
  -                  "Unable to construct a valid URL from the base: " 
  -                    + parent.getURL() + " with the name: " + name;
  -                throw new ApplianceRuntimeException( error, e );
  -            }
  +            final String error = 
  +              "Unable to construct a valid URL from the base: " 
  +               + parent.getURL() + " with the name: " + name;
  +            throw new ApplianceRuntimeException( error, e );
           }
       }
   
  @@ -161,6 +164,24 @@
       //==================================================================
   
      /**
  +    * Creation of a new repository as child to this repository.
  +    * @param engine the engine to assign
  +    * @param name the repository name
  +    * @return the repository
  +    */
  +    public ApplianceRepository createChild( Engine engine, String name )
  +    {
  +        ApplianceRepository repository = 
  +          new DefaultApplianceRepository( engine, this, name );
  +
  +        final String key = 
  +          repository.getURL().getPath().substring( getURL().getPath().length() );
  +
  +        m_children.put( key, repository );
  +        return repository;
  +    }
  +
  +   /**
       * Return the repository URL.
       * @return the URL for the repository.
       */
  @@ -176,18 +197,29 @@
       */
       public Appliance[] getAppliances( DependencyDescriptor dependency )
       {
  +        ReferenceDescriptor reference = dependency.getReference();
  +        return getAppliances( reference );
  +    }
  +
  +   /**
  +    * Return the set of appliance instances capable of supporting the supplied 
  +    * service reference.
  +    * @param reference a service reference
  +    * @return a set of candidate appliances
  +    */
  +    public Appliance[] getAppliances( ReferenceDescriptor reference )
  +    {
           ArrayList list = new ArrayList();
           if( m_parent != null )
           {
  -            Appliance[] appliances = m_parent.getAppliances( dependency );
  +            Appliance[] appliances = m_parent.getAppliances( reference );
               for( int i=0; i<appliances.length; i++ )
               {
                   list.add( appliances[i] );
               }
           }
   
  -        ReferenceDescriptor reference = dependency.getReference();
  -        Iterator iterator = m_appliances.iterator();
  +        Iterator iterator = m_appliances.values().iterator();
           while( iterator.hasNext() )
           {
               Appliance appliance = (Appliance) iterator.next();
  @@ -197,10 +229,10 @@
                   list.add( appliance );
               }
           }
  -
           return (Appliance[]) list.toArray( new Appliance[0] );
       }
   
  +
      /**
       * Return the set of appliance instances that provide the supplied extension.
       * @param stage a stage descriptor
  @@ -218,7 +250,7 @@
               }
           }
   
  -        Iterator iterator = m_appliances.iterator();
  +        Iterator iterator = m_appliances.values().iterator();
           while( iterator.hasNext() )
           {
               Appliance appliance = (Appliance) iterator.next();
  @@ -246,6 +278,29 @@
       }
   
      /**
  +    * Select an appliance supporting the supplied service reference.
  +    * @param reference a service reference descriptor
  +    * @return the selected appliance (possibly null)
  +    */
  +    public Appliance getAppliance( ReferenceDescriptor reference )
  +    {
  +        return getAppliance( reference, new DefaultApplianceSelector() );
  +    }
  +
  +   /**
  +    * Select an appliance supporting the supplied service reference using a supplied selector.
  +    * @param reference a service reference descriptor
  +    * @param selector the appliance selector
  +    * @return the selected appliance (possibly null)
  +    */
  +    public Appliance getAppliance( ReferenceDescriptor reference, ApplianceSelector selector )
  +    {
  +        Appliance[] appliances = getAppliances( reference );
  +        DependencyDescriptor dependency = new DependencyDescriptor( "", reference );
  +        return selector.select( appliances, dependency );
  +    }
  +
  +   /**
       * Select an appliance capable of supporting the supplied stage 
       * @param stage a lifecycle stage
       * @param selector an appliance selector
  @@ -281,19 +336,66 @@
        * Add a appliance to the manager.
        * @param appliance the appliance to add to the manager
        * @exception DuplicateApplianceException if an appliance has already been registered
  -     *   for the undrlying profile
  +     *   for the underlying profile
        * @exception NullPointerException if the supplied appliance is null.
        */
  -    public void addAppliance( Appliance appliance ) throws DuplicateApplianceException, NullPointerException
  +    public void addAppliance( Appliance appliance ) 
  +      throws DuplicateApplianceException, NullPointerException
       {
           if( appliance == null )
           {
               throw new NullPointerException( "appliance" );
           }
  -        if( m_appliances.contains( appliance ) )
  +
  +        if( m_appliances.values().contains( appliance ) )
           {
               throw new DuplicateApplianceException( appliance.toString() );
           }
  -        m_appliances.add( appliance );
  +        
  +        final String local = getURL().getPath();
  +        if( appliance.getURL().getPath().startsWith( local ) )
  +        {
  +            final String key = appliance.getURL().getPath().substring( local.length() );
  +            m_appliances.put( key , appliance );
  +        }
  +        else
  +        {
  +            final String error = 
  +              "Appliance URL " + appliance.getURL() 
  +              + " does not match repository URL " + getURL(); 
  +            throw new ApplianceRuntimeException( error );
  +        }
  +    }
  +
  +   /**
  +    * Return an appliance relative to the supplied path.
  +    * @param uri the appliance path
  +    */
  +    public Appliance resolve( String uri )
  +    {        
  +        if( uri.startsWith( m_url.getPath() ) )
  +        {
  +            // its in scope so substract the path of this repository
  +            // from the supplied uri then get the name of the child
  +
  +            String path = uri.substring( m_url.getPath().length() );
  +            
  +            if( path.indexOf( "/" ) > -1 )
  +            {
  +                // looking for a child
  +                String name = path.substring( 0, path.indexOf( "/" ) +1 );
  +                ApplianceRepository child = (ApplianceRepository) m_children.get( name );
  +                if( child != null )
  +                {
  +                    return child.resolve( uri );
  +                }
  +            }
  +            else
  +            {
  +                // looking for an appliance
  +                return (Appliance) m_appliances.get( path );
  +            }
  +        }
  +        return null;
       }
   }
  
  
  
  1.3       +16 -3     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java
  
  Index: EngineClassLoader.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/engine/EngineClassLoader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EngineClassLoader.java	29 Mar 2003 03:25:56 -0000	1.2
  +++ EngineClassLoader.java	6 Apr 2003 19:24:51 -0000	1.3
  @@ -745,8 +745,7 @@
   
               engine.enableLogging( getLogger() );
               DefaultLocator context = new DefaultLocator();
  -            DefaultApplianceRepository manager = 
  -              new DefaultApplianceRepository( this, m_manager, name );
  +            ApplianceRepository manager = m_manager.createChild( engine, name );
   
               context.put( "urn:assembly:appliance.repository", manager );
               context.put( "urn:assembly:home", m_home );
  @@ -926,6 +925,20 @@
                 "Unexpected error during type registration.";
               throw new EngineRuntimeException( error, e );
           }
  +    }
  +
  +   /**
  +    * Resolve an appliance capable of supporting a service 
  +    * reference.
  +    *
  +    * @param reference a service reference descriptor
  +    * @return the appliance
  +    */
  +    public Appliance resolve( ReferenceDescriptor reference ) 
  +      throws Exception
  +    {
  +        DependencyDescriptor dependency = new DependencyDescriptor( "", reference );
  +        return resolve( new DependencyGraph(), dependency, "" );
       }
   
      /**
  
  
  
  1.2       +36 -2     avalon-sandbox/merlin/assembly-spi/src/java/org/apache/avalon/assembly/appliance/ApplianceRepository.java
  
  Index: ApplianceRepository.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly-spi/src/java/org/apache/avalon/assembly/appliance/ApplianceRepository.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ApplianceRepository.java	13 Mar 2003 01:04:37 -0000	1.1
  +++ ApplianceRepository.java	6 Apr 2003 19:24:51 -0000	1.2
  @@ -57,9 +57,11 @@
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.meta.info.DependencyDescriptor;
  +import org.apache.avalon.meta.info.ReferenceDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.model.Profile;
   import org.apache.avalon.assembly.logging.LoggingManager;
  +import org.apache.avalon.assembly.engine.Engine;
   
   /**
    * An appliance manager implemetation provides support for the 
  @@ -68,7 +70,7 @@
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  -public interface ApplianceRepository 
  +public interface ApplianceRepository extends ApplianceResolver
   {
      /**
       * Return the base URL for the repository.
  @@ -76,6 +78,14 @@
       */
       URL getURL();
   
  +   /**
  +    * Creation of a new repository as child to this repository.
  +    * @param engine the engine to assign
  +    * @param name the repository name
  +    * @return the repository
  +    */
  +    ApplianceRepository createChild( Engine engine, String name );
  +
       /**
        * Add a appliance to the manager.
        * @param appliance the appliance to add to the manager
  @@ -97,6 +107,30 @@
       * @return a set of candidate appliances
       */
       Appliance[] getAppliances( StageDescriptor stage );
  +
  +   /**
  +    * Return the set of appliance istances capable of supporting the supplied 
  +    * service reference.
  +    * @param reference a service reference
  +    * @return a set of candidate appliances
  +    */
  +    Appliance[] getAppliances( ReferenceDescriptor reference );
  +
  +   /**
  +    * Select an appliance supporting the supplied service reference.
  +    * @param reference a service reference descriptor
  +    * @return the selected appliance (possibly null)
  +    */
  +    Appliance getAppliance( ReferenceDescriptor reference );
  +
  +   /**
  +    * Select an appliance supporting the supplied service reference 
  +    *  using a supplied selector.
  +    * @param reference a service reference descriptor
  +    * @param selector the appliance selector
  +    * @return the selected appliance (possibly null)
  +    */
  +    Appliance getAppliance( ReferenceDescriptor reference, ApplianceSelector selector );
   
      /**
       * Select an appliance supporting the supplied dependency using a supplied selector.
  
  
  
  1.2       +12 -1     avalon-sandbox/merlin/assembly-spi/src/java/org/apache/avalon/assembly/engine/Engine.java
  
  Index: Engine.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly-spi/src/java/org/apache/avalon/assembly/engine/Engine.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Engine.java	13 Mar 2003 01:04:39 -0000	1.1
  +++ Engine.java	6 Apr 2003 19:24:51 -0000	1.2
  @@ -54,6 +54,7 @@
   import org.apache.avalon.assembly.appliance.ApplianceException;
   import org.apache.avalon.assembly.appliance.ApplianceContext;
   import org.apache.avalon.assembly.appliance.DependencyGraph;
  +import org.apache.avalon.meta.info.ReferenceDescriptor;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
   
  @@ -105,6 +106,16 @@
       */
       Appliance createAppliance( 
         ApplianceContext context, boolean shared, boolean nested ) throws ApplianceException;
  +
  +   /**
  +    * Resolve an appliance capable of supporting a service 
  +    * reference.
  +    *
  +    * @param reference a service reference descriptor
  +    * @return the appliance
  +    */
  +    public Appliance resolve( ReferenceDescriptor reference ) 
  +      throws Exception;
   
      /**
       * Resolve an appliance capable of supporting a supplied service 
  
  
  
  1.6       +2 -2      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultBlockLoader.java	2 Apr 2003 15:58:05 -0000	1.5
  +++ DefaultBlockLoader.java	6 Apr 2003 19:24:51 -0000	1.6
  @@ -797,7 +797,7 @@
   
           try
           {
  -            return (Block) engine.createAppliance( context, false, false );
  +            return (Block) engine.createAppliance( context, true );
           }
           catch( Throwable e )
           {
  
  
  
  1.3       +74 -19    avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernel.java
  
  Index: DefaultKernel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/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	29 Mar 2003 03:25:57 -0000	1.2
  +++ DefaultKernel.java	6 Apr 2003 19:24:52 -0000	1.3
  @@ -253,6 +253,11 @@
       private String m_debug;
   
      /**
  +    * The default logging level.
  +    */
  +    private String m_priority = null;
  +
  +   /**
       * Flag holding the initalized state of the kernel.
       */
       private boolean m_initialized = false;
  @@ -296,6 +301,11 @@
       *     <td>The system logging priority (a value of INFO, WARN, ERROR, or DEBUG.</td> 
       *   </tr>
       *   <tr>
  +    *     <td><code>urn:merlin:logging.priority</code></td>
  +    *     <td>{@link java.lang.String}</td>
  +    *     <td>The default logging priority (a value of INFO, WARN, ERROR, or DEBUG.</td> 
  +    *   </tr>
  +    *   <tr>
       *     <td><code>urn:merlin:block.url</code></td>
       *     <td>{@link java.net.URL}</td>
       *     <td>The url to the block.xml file.</td> 
  @@ -333,17 +343,22 @@
           }
   
           //
  -        // get the root block if an only if it is declared
  -        // in the context
  +        // get the root block url
           //
   
  -        if( context.hasEntry( "urn:merlin:block.url" ) )
  +        m_url = (URL) context.get( "urn:merlin:block.url" );
  +        if( context.hasEntry( "urn:merlin:block.config" ) )
           {
  -            m_url = (URL) context.get( "urn:merlin:block.url" );
  -            if( context.hasEntry( "urn:merlin:block.config" ) )
  -            {
  -                m_override = (URL) context.get( "urn:merlin:block.config" );
  -            }
  +            m_override = (URL) context.get( "urn:merlin:block.config" );
  +        }
  +
  +        //
  +        // get the default logging priority
  +        //
  +
  +        if( context.hasEntry( "urn:merlin:logging.priority" ) )
  +        {
  +            m_priority = (String) context.get( "urn:merlin:logging.priority" );
           }
   
           m_contextualized = true;
  @@ -386,6 +401,11 @@
                throw new IllegalStateException("context");
           }
   
  +        if( m_config == null )
  +        {
  +             m_config = new DefaultConfiguration("kernel", "DefaultKernel");
  +        }
  +
           setShutdownHook( this );
   
           //
  @@ -397,7 +417,9 @@
               final String sys = "/sys";
               if( m_logging == null )
               {
  -                m_logging = bootstrapLoggingManager( Container.PATH_SEPERATOR, sys, null );
  +                m_logging = bootstrapLoggingManager( 
  +                  Container.PATH_SEPERATOR, sys, m_priority );
  +
                   Configuration categoriesConfig = m_config.getChild( "categories" );
   
                   //
  @@ -480,7 +502,7 @@
           }
           catch( Throwable e )
           {
  -            final String error = "Block installer establishmet failure.";
  +            final String error = "Block installer establishment failure.";
               String log = ExceptionHelper.packException( error, e );
               if( getLogger().isErrorEnabled() )
               {
  @@ -492,7 +514,7 @@
           m_initialized = true;
   
           //
  -        // install a block if a block URL was included in the context argument
  +        // install the root block
           //
   
           try
  @@ -506,7 +528,7 @@
           }
           catch( Throwable e )
           {
  -            final String error = "Root block instalation failure.";
  +            final String error = "Root block installation failure.";
               String log = ExceptionHelper.packException( error, e );
               if( getLogger().isErrorEnabled() )
               {
  @@ -521,6 +543,19 @@
       //==============================================================
   
      /**
  +    * Return the root block.
  +    * @return the root block
  +    */
  +    public Block getRootBlock()
  +    {
  +        return m_block;
  +    }
  +
  +    //==============================================================
  +    // DefaultKernel
  +    //==============================================================
  +
  +   /**
       * Install a block into the kernel.
       * @param base the URL of the block configuration or a jar file 
       *   containing a block descriptor
  @@ -530,7 +565,7 @@
       * @exception KernelException if an installation error if raised
       * @exception NullPointerException if the supplied base URL is null
       */
  -    public Block install( URL base, URL config ) throws KernelException
  +    private Block install( URL base, URL config ) throws KernelException
       {
           if( base == null )
           {
  @@ -624,10 +659,6 @@
           return block;
       }
   
  -    //==============================================================
  -    // DefaultKernel
  -    //==============================================================
  -
      /**
       * Shutdown the kernel during which orderly shutdown of all 
       * installed blocks is undertaken.
  @@ -799,6 +830,29 @@
               context.makeReadOnly();
               engine.contextualize( context );
               engine.initialize();
  +
  +            //
  +            // make sure that the merlin internal components are registered
  +            // (problem occurs when running under a junit test where the 
  +            // classloader does not expose the loaded jar files)
  +            //
  +
  +            try
  +            {
  +                engine.register( 
  +                  "org.apache.avalon.assembly.lifecycle.context.DefaultContextualizer" );
  +                engine.register( 
  +                  "org.apache.avalon.assembly.lifecycle.context.AvalonContextualizer" );
  +                engine.register( 
  +                  "org.apache.avalon.merlin.container.impl.DefaultContainer" );
  +                engine.register( 
  +                  "org.apache.avalon.merlin.block.impl.DefaultBlock" );
  +            }
  +            catch( Throwable e )
  +            {
  +                // already registered
  +            }
  +
               return engine;
           }
           catch( Throwable e )
  @@ -814,7 +868,8 @@
       */
       public String toString()
       {
  -        StringBuffer buffer = new StringBuffer( "DefaultKernel: " + System.identityHashCode( this ) );
  +        StringBuffer buffer = 
  +          new StringBuffer( "DefaultKernel: " + System.identityHashCode( this ) );
   
           if( m_block != null )
           {
  
  
  
  1.3       +1 -0      avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernel.xinfo
  
  Index: DefaultKernel.xinfo
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernel.xinfo,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultKernel.xinfo	29 Mar 2003 03:25:57 -0000	1.2
  +++ DefaultKernel.xinfo	6 Apr 2003 19:24:52 -0000	1.3
  @@ -23,6 +23,7 @@
   
     <context>
       <entry key="urn:merlin:home" type="java.io.File" />
  +    <entry key="urn:merlin:logging.priority" optional="true"/>
       <entry key="urn:merlin:classloader.common" type="java.lang.ClassLoader" />
       <entry key="urn:merlin:classloader.system" type="java.lang.ClassLoader" />
       <entry key="urn:merlin:block.url" type="java.net.URL" />
  
  
  
  1.2       +4 -10     avalon-sandbox/merlin/merlin-spi/src/java/org/apache/avalon/merlin/kernel/Kernel.java
  
  Index: Kernel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-spi/src/java/org/apache/avalon/merlin/kernel/Kernel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Kernel.java	13 Mar 2003 01:05:56 -0000	1.1
  +++ Kernel.java	6 Apr 2003 19:24:52 -0000	1.2
  @@ -70,16 +70,10 @@
       //=======================================================================
   
      /**
  -    * Install a block into the kernel.
  -    * @param base the URL of the block configuration or a jar file 
  -    *   containing a block descriptor
  -    * @param config a possibly null URL of a configuration file
  -    *   containing component configuration targets
  -    * @return the installed block
  -    * @exception KernelException if an installation error if raised
  -    * @exception NullPointerException if the supplied base URL is null
  +    * Return the root block.
  +    * @return the root block
       */
  -    Block install( URL base, URL config ) throws KernelException;
  +    Block getRootBlock();
   
      /**
       * Initiate an orderly shutdown of the kernel.
  
  
  

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