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/meta-spi/src/java/org/apache/avalon/meta/info ReferenceDescriptor.java
Date Thu, 10 Apr 2003 04:36:15 GMT
mcconnell    2003/04/09 21:36:14

  Modified:    merlin   maven.xml
               merlin/assembly/src/java/org/apache/avalon/assembly/appliance
                        ApplianceHolder.java DefaultAppliance.java
                        DefaultApplianceFactory.java
                        DefaultApplianceRepository.java
               merlin/assembly/src/java/org/apache/avalon/assembly/engine
                        EngineClassLoader.java
               merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle
                        AbstractLifestyleHandler.java LifestyleHandler.java
               merlin/assembly-spi/src/java/org/apache/avalon/assembly/appliance
                        Appliance.java
               merlin/assembly-spi/src/java/org/apache/avalon/assembly/locator
                        Resolvable.java
               merlin/merlin-cli/src/java Merlin.java
               merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl
                        DefaultBlock.java
               merlin/merlin-core/src/java/org/apache/avalon/merlin/kernel/impl
                        DefaultKernel.java
               merlin/merlin-smp/src/examples/afs/simple/conf block.xml
               merlin/merlin-smp/src/examples/afs/simple/src/java/org/apache/bank/impl
                        Accounts.java BankProvider.java BankProvider.xinfo
               merlin/merlin-smp/src/examples/afs/simple/src/test/org/apache/bank
                        BankTestCase.java
               merlin/merlin-smp/src/examples/afs/simple-servlet maven.xml
               merlin/merlin-smp/src/examples/afs/simple-servlet/src/java/org/apache/bank
                        SimpleServlet.java
               merlin/merlin-smp/xdocs/tools navigation.xml
               merlin/meta-spi/src/java/org/apache/avalon/meta/info
                        ReferenceDescriptor.java
  Added:       merlin/assembly project.properties
               merlin/assembly/src/java/org/apache/avalon/assembly/appliance
                        BlockURLConnection.java BlockURLHandler.java
               merlin/assembly-spi/src/java/org/apache/avalon/assembly/appliance
                        CascadingIOException.java
  Removed:     merlin/assembly/src/java/org/apache/avalon/assembly/appliance
                        ApplianceHandler.java ApplianceURLConnection.java
  Log:
  Updates supporting URL based aquisition of component handlers and services.
  
  Revision  Changes    Path
  1.6       +18 -0     avalon-sandbox/merlin/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/maven.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- maven.xml	2 Apr 2003 15:58:38 -0000	1.5
  +++ maven.xml	10 Apr 2003 04:36:12 -0000	1.6
  @@ -175,6 +175,24 @@
       </copy>
     </goal>
   
  +  <goal name="merlin-libs" prereqs="merlin-install-plugin,merlin-dist">
  +    <property environment="env"/>
  +    <mkdir dir="${env.MERLIN_HOME}/lib/shared"/>
  +    <echo>Updating Merlin libraries: ${env.MERLIN_HOME}</echo>
  +    <copy toDir="${env.MERLIN_HOME}/lib/shared">
  +      <fileset dir="${merlin.build.inst.dir}/lib/shared">
  +        <include name="**/*"/>
  +      </fileset>
  +    </copy>
  +    <mkdir dir="${env.MERLIN_HOME}/lib/system"/>
  +    <copy toDir="${env.MERLIN_HOME}/lib/system">
  +      <fileset dir="${merlin.build.inst.dir}/lib/system">
  +        <include name="**/*"/>
  +      </fileset>
  +    </copy>
  +  </goal>
  +
  +
     <!--
     Install the merlin plugin into the Maven plugin suite.
     -->
  
  
  
  1.1                  avalon-sandbox/merlin/assembly/project.properties
  
  Index: project.properties
  ===================================================================
  
  maven.junit.fork = true
  
  
  
  1.2       +7 -1      avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceHolder.java
  
  Index: ApplianceHolder.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/ApplianceHolder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ApplianceHolder.java	13 Mar 2003 01:03:39 -0000	1.1
  +++ ApplianceHolder.java	10 Apr 2003 04:36:13 -0000	1.2
  @@ -72,4 +72,10 @@
       {
           return m_appliance;
       }
  +
  +    public Object resolve( Object partition, String ref )
  +    {
  +        return m_appliance;
  +    }
  +
   }
  
  
  
  1.7       +72 -13    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultAppliance.java	6 Apr 2003 19:24:51 -0000	1.6
  +++ DefaultAppliance.java	10 Apr 2003 04:36:13 -0000	1.7
  @@ -72,6 +72,7 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.meta.info.ContextDescriptor;
   import org.apache.avalon.meta.info.DependencyDescriptor;
  +import org.apache.avalon.meta.info.ServiceDescriptor;
   import org.apache.avalon.meta.info.ReferenceDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
   import org.apache.avalon.meta.info.Type;
  @@ -142,9 +143,6 @@
   
       protected static String PROTOCOL = "native";
   
  -    // NEVER USED!
  -    //private static final ContextBuilder BUILDER = new ContextBuilder();
  -
       //=====================================================================
       // state
       //=====================================================================
  @@ -338,6 +336,20 @@
       public Object resolve( Object partition )
           throws LocatorException
       {
  +        return resolve( partition, null );
  +    }
  +
  +    /**
  +     * Resolve a object to a value qualified by a supplied service reference.
  +     *
  +     * @param partition the context within the the resolution is applied
  +     * @param ref the service reference
  +     * @return the resolved object
  +     * @throws ContextException if an error occurs
  +     */
  +    public Object resolve( Object partition, String ref )
  +        throws LocatorException
  +    {
           if( !m_assembled )
           {
               final String message = 
  @@ -350,14 +362,37 @@
               catch( ApplianceException ae )
               {
                   final String error = 
  -                  "Unable to resolve service due to a self assembly failure in applaince: " + this;
  -                throw new LocatorException( error, ae );
  +                  "Unable to resolve service due to a self assembly failure in appliance: " 
  +                  + this;
  +                throw new LocatorException( error, ref, ae );
  +            }
  +        }
  +
  +        if( ref != null )
  +        {
  +            if( !validReference( ref ) )
  +            {
  +                final String error = 
  +                  "Requested service ref: " + ref 
  +                  + " is unknown within appliance: " + this;
  +                throw new LocatorException( ref, error );
               }
           }
  -        return m_handler.resolve( partition );
  +
  +        try
  +        {
  +            return m_handler.resolve( partition, ref );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Internal lifestyle handler error during qualified resolution "
  +              + " relative to reference: " + ref;
  +            throw new LocatorException( ref, error, e );
  +        }
       }
   
  -    /**
  +    /**s
        * Release an object
        *
        * @param the object to be reclaimed
  @@ -432,21 +467,31 @@
       }
   
      /**
  -    * Get the URL for a service.
  -    * @param reference the service reference descriptor
  +    * Get the URL for the supplied service type
  +    * @param type the service type ref
       * @return the service URL
  +    * @exception UnknownServiceException if the supplied reference is unknown 
  +    *   to the appliance.
       */
  -    public URL getURL( ReferenceDescriptor reference ) throws UnknownServiceException
  +    public URL getURL( String type ) throws UnknownServiceException
       {
  +        if( !validReference( type ) )
  +        {
  +            final String error = 
  +              "Requested service ref: " + type 
  +              + " is unknown within appliance: " + this;
  +            throw new UnknownServiceException( error );
  +        }
  +
           try
           {
               final URL url = getURL();
  -            return new URL( url, url.getPath() + "?service=" + reference.toString() );
  +            return new URL( url, url.getPath() + "#" + type );
           }
           catch( Throwable e )
           {
               final String error =
  -              "Unexpected error while creating a URL for service: " + reference;
  +              "Unexpected error while creating a URL for service: " + type;
               throw new ApplianceRuntimeException( error, e );
           }
       }
  @@ -1009,4 +1054,18 @@
               }
           }
       }
  +
  +   /**
  +    * Internal utility to check if a supplied type is exposed as a service.
  +    * @return true if there is a matching service description for the type
  +    *   published by the type associated with the profile that this appliance
  +    *   is handling.
  +    */
  +    private boolean validReference( String ref )
  +    {
  +        ServiceDescriptor service = 
  +          getType().getService( new ReferenceDescriptor( ref ) );
  +        return service != null;
  +    }
  +
   }
  
  
  
  1.3       +2 -2      avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceFactory.java
  
  Index: DefaultApplianceFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/DefaultApplianceFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultApplianceFactory.java	17 Mar 2003 02:44:14 -0000	1.2
  +++ DefaultApplianceFactory.java	10 Apr 2003 04:36:13 -0000	1.3
  @@ -166,7 +166,7 @@
           //
           // we are building a custom appliance factory
           // 
  -          
  +
           try
           {
               Type type = loader.getRepository().getTypeManager()
  
  
  
  1.3       +14 -14    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultApplianceRepository.java	6 Apr 2003 19:24:51 -0000	1.2
  +++ DefaultApplianceRepository.java	10 Apr 2003 04:36:13 -0000	1.3
  @@ -68,7 +68,6 @@
    * The default appliance manager provides support for {@link Appliance}
    * registration and retrival.
    *
  - * @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
  @@ -76,7 +75,6 @@
   public final class DefaultApplianceRepository 
     implements ApplianceRepository
   {
  -
       //==================================================================
       // state
       //==================================================================
  @@ -97,11 +95,6 @@
       private final Map m_children = new Hashtable();
           
      /**
  -    * The engine.
  -    */
  -    private Engine m_engine;
  -
  -   /**
       * The name of the manager.
       */
       private String m_name;
  @@ -115,14 +108,17 @@
       // constructor
       //==============================================================
   
  -    public DefaultApplianceRepository( Engine engine )
  +   /**
  +    * Creation of a root appliance repository.
  +    */
  +    public DefaultApplianceRepository()
       {
  -        m_engine = engine;
           m_name = "/";
  +
           try
           {
               m_url = new URL( 
  -              "appliance", "localhost", -1, m_name, new ApplianceHandler( this ) );
  +              "block", "localhost", -1, m_name, new BlockURLHandler( this ) );
           }
           catch( Throwable e )
           {
  @@ -132,10 +128,14 @@
           }
       }
   
  -    private DefaultApplianceRepository( Engine engine, ApplianceRepository parent, String name )
  +   /**
  +    * Internal constructor suppoerting the creation of a subsidiary repository.
  +    * @param parent the parent repository
  +    * @param name the subsidiary repository name
  +    */
  +    private DefaultApplianceRepository( ApplianceRepository parent, String name )
       {
           m_parent = parent;
  -        m_engine = engine;
           m_name = name;
   
           final URL url = parent.getURL();
  @@ -172,7 +172,7 @@
       public ApplianceRepository createChild( Engine engine, String name )
       {
           ApplianceRepository repository = 
  -          new DefaultApplianceRepository( engine, this, name );
  +          new DefaultApplianceRepository( this, name );
   
           final String key = 
             repository.getURL().getPath().substring( getURL().getPath().length() );
  
  
  
  1.1                  avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/BlockURLConnection.java
  
  Index: BlockURLConnection.java
  ===================================================================
  /* ==================================================================== 
   * The Apache Software License, Version 1.1 
   * 
   * Copyright (c) 2002 The Apache Software Foundation. All rights 
   * reserved. 
   * 
   * Redistribution and use in source and binary forms, with or without 
   * modification, are permitted provided that the following conditions 
   * are met: 
   * 
   * 1. Redistributions of source code must retain the above copyright 
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software 
   *    itself, if and wherever such third-party acknowledgments  
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see 
   * <http://www.apache.org/>.
   */ 
  
  package org.apache.avalon.assembly.appliance;
  
  import java.io.IOException;
  import java.net.URL;
  import java.net.URLConnection;
  
  import org.apache.avalon.assembly.appliance.Appliance;
  import org.apache.avalon.assembly.appliance.ApplianceRepository;
  import org.apache.avalon.assembly.appliance.CascadingIOException;
  
  /**
   * URL connection handler for the service protocol. New instances of
   * the <code>ServiceURLConnection</code> are created by a service
   * URL <code>Handler</code> class.
   * @see Handler
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   */
  public class BlockURLConnection extends URLConnection
  {
  
      /**
       * The appliance repository from which the appliance instance is resolved.
       */
      private ApplianceRepository m_repository;
  
      /**
       * The URL passed in during the creation of the URL Connection 
       * by the protocol handler.
       */
       private URL m_url;
  
      /**
       * Creation of a new <code>ApplianceURLConnection</code> handler.
       * @param url the base URL
       * @param repository the root appliance repository
       * @param ref the service reference
       */
      public BlockURLConnection( URL url, ApplianceRepository repository )
      {
          super( url );
          if( repository == null )
          {
              throw new NullPointerException( "repository" );
          }
          if( url == null )
          {
              throw new NullPointerException( "url" );
          }
          m_repository = repository;
          m_url = url;
      }
  
      /**
       * Establishment of a connection to the object defined by the URL.
       *
       * @exception IOException if an error is raised while attempting to
       *  establish the connection.
       */
      public void connect() throws IOException
      {
          // nothing to do
      }
  
      /**
       * Returns the object referenced by the URL.
       * @return and appliance instance
       * @exception IOException if an error occurs while attempting to retireve
       *   the object reference.
       */
      public Object getContent() throws IOException
      {
          return getContent( new Class[0] );
      }
  
      /**
       * Retrieves the contents of this URL connection.
       *
       * @param classes the <code>Class</code> array
       * indicating the requested types
       * @return     the object fetched that is the first match of the type
       *               specified in the classes array. null if none of
       *               the requested types are supported.
       *               The <code>instanceOf</code> operation should be used to
       *               determine the specific kind of object returned.
       * @exception  IOException              if an I/O error occurs while
       *               getting the content.
       */
      public Object getContent( Class[] classes ) throws IOException
      {
          Appliance appliance = m_repository.resolve( m_url.getPath() );
          final String ref = m_url.getRef();
          if( ref == null )
          {
              return appliance;
          }
  
          //
          // otherwise resolve the service relative to the #ref 
          //
  
          try
          {
              return appliance.resolve( m_url, ref );
          }
          catch( Throwable e )
          {
              final String error = 
                "URL content resolution error in: " + m_url;
              throw new CascadingIOException( error, e );
          }
      }
  }
  
  
  
  1.1                  avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/appliance/BlockURLHandler.java
  
  Index: BlockURLHandler.java
  ===================================================================
  /* ==================================================================== 
   * The Apache Software License, Version 1.1 
   * 
   * Copyright (c) 2002 The Apache Software Foundation. All rights 
   * reserved. 
   * 
   * Redistribution and use in source and binary forms, with or without 
   * modification, are permitted provided that the following conditions 
   * are met: 
   * 
   * 1. Redistributions of source code must retain the above copyright 
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *    "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software 
   *    itself, if and wherever such third-party acknowledgments  
   *    normally appear.
   *
   * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" 
   *    must not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation. For more
   * information on the Apache Software Foundation, please see 
   * <http://www.apache.org/>.
   */ 
  
  package org.apache.avalon.assembly.appliance;
  
  import java.io.IOException;
  import java.net.URL;
  import java.net.URLConnection;
  import java.net.URLStreamHandler;
  
  import org.apache.avalon.assembly.appliance.ApplianceRepository;
  
  /**
   * <p>A URL handler for the appliance protocol.<p>
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   */
  public final class BlockURLHandler extends URLStreamHandler
  {
  
      /**
       * The root appliance manager.
       */
      private ApplianceRepository m_repository;
  
      /**
       * Internal debug flag.
       */
      private boolean debug = false;
  
      /**
       * Creation of a new handler.
       * @param repository the appliance repository
       */
      public BlockURLHandler( ApplianceRepository repository )
      {
          if( repository == null ) 
          {
              throw new NullPointerException( "repository" );
          }
  
          m_repository = repository;
      }
  
      /**
       * Opens a connection to the specified URL.
       *
       * @param url A URL to open a connection to.
       * @return The established connection.
       * @throws IOException If a connection failure occurs.
       */
      protected URLConnection openConnection( final URL url )
          throws IOException
      {
          return new BlockURLConnection( url, m_repository );
      }
  
      /**
       * Parses the string representation of a <code>URL</code> into a
       * <code>URL</code> object.
       * e.g. block://localhost/root#org.apache.playground.Demo
       * e.g. block://localhost/root/subcontainer/demo
       * <p>
       * If there is any inherited context, then it has already been
       * copied into the <code>URL</code> argument.
       *
       * @param   url     the <code>URL</code> to receive the result of parsing
       *                  the spec.
       * @param   spec    the <code>String</code> representing the URL that
       *                  must be parsed.
       * @param   start   the character index at which to begin parsing. This is
       *                  just past the '<code>:</code>' (if there is one) that
       *                  specifies the determination of the protocol name.
       * @param   limit   the character position to stop parsing at. This is the
       *                  end of the string or the position of the
       *                  "<code>#</code>" character, if present. All information
       *                  after the sharp sign indicates an anchor.
       */
      protected void parseURL( URL url, String spec, int start, int limit )
      {
          //
          // get the ref component
          // (from # to the end of the spec)
          //
  
          String ref = url.getRef();
          String remainder = spec.substring( start, limit );
          int refLoc = spec.indexOf( "#", start );
          if( refLoc > -1 )
          {
              ref = spec.substring( refLoc + 1 );
              remainder = spec.substring( start, refLoc );
          }
  
          //
          // get the query component
          // (from ? to the end of the remainder)
          //
  
          String query = url.getQuery();
          int queryLoc = remainder.indexOf( "?" );
          if( queryLoc > -1 )
          {
              query = remainder.substring( queryLoc + 1, remainder.length() );
              remainder = remainder.substring( 0, queryLoc );
          }
  
          //
          // get the path component
          // (from / to the end of the remainder)
          //
  
          if( remainder.startsWith( "//" ) )
          {
              remainder = remainder.substring( 2, remainder.length() );
          }
  
          String path = url.getPath();
  
          if( remainder.startsWith( "/" ) )
          {
              // its an absolute spec
              path = remainder;
          }
          else if( remainder.startsWith( "./" ) )
          {
              path = path + remainder.substring( 2 );
          }
          else
          {
              path = path + remainder;
          }
  
          path = clean( compactPath( path ) );
  
          //
          // set the URL parameters
          //
  
          String user = url.getUserInfo();
  
          String host = url.getHost();
          if( host == null ) 
          {
              host = "localhost";
          }
  
          int port = url.getPort();
          if( port == -1 ) 
          {
              port = getDefaultPort();
          }
  
          //
          // create authority string dependending of non-default port reference
          //
  
          String authority = null;
          if( port == getDefaultPort() )
          {
              authority = host;
          }
          else
          {
              authority = host + ":" + port;
          }
  
          setURL( url, "block", host, port, authority, user, path, query, ref );
  
          if( debug )
          {
              System.out.println( "BASE: " + url );
              System.out.println( "HOST: " + host );
              System.out.println( "PORT: " + port );
              System.out.println( "AUTHORITY: " + authority );
              System.out.println( "USER: " + user );
              System.out.println( "PATH: " + path );
              System.out.println( "QUERY: " + query );
              System.out.println( "REF: " + ref );
          }
      }
  
      private String clean( String path )
      {
          int flag = path.indexOf( "/./" );
          if( flag == -1 )
          {
              return path;
          }
          final String head = path.substring( 0, flag );
          final String tail = path.substring( flag+2 );
          return clean( head + tail );
      }
  
      private String compactPath( String path )
      {
          int p = path.indexOf( "/../" );
          if( p == -1 )
          {
              return path;
          }
  
          final String header = path.substring( 0, p );
          int n = header.lastIndexOf( "/" );
          final String stub = header.substring( 0, n +1 );
  
          if( stub.length() > 0 )
          {
              final String result = stub + path.substring( p + 4 );
              return compactPath( result );
          }
          else
          {
              throw new IllegalArgumentException( "Invalid path: " + path );
          }
      }
  
  
  
      /**
       * Retuns the default port.
       * @return int the default port value of 0
       */
      protected int getDefaultPort()
      {
          return 0;
      }
  
      /**
       * Returns the URL in a string form.
       * @param url to the URL to externalize
       * @return String the external form of the URL
       */
      protected String toExternalForm( URL url )
      {
          StringBuffer result = new StringBuffer( url.getProtocol() );
          result.append( "://" );
          result.append( url.getHost() );
          if( url.getUserInfo() != null )
          {
              result.append( "@" );
              result.append( url.getUserInfo() );
          }
          if( url.getFile() != null )
          {
              result.append( url.getFile() );
          }
          if( url.getRef() != null )
          {
              result.append( "#" );
              result.append( url.getRef() );
          }
          return result.toString();
      }
  }
  
  
  
  
  1.4       +4 -18     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EngineClassLoader.java	6 Apr 2003 19:24:51 -0000	1.3
  +++ EngineClassLoader.java	10 Apr 2003 04:36:13 -0000	1.4
  @@ -136,7 +136,7 @@
       //==============================================================
   
       private static final Resources REZ =
  -        ResourceManager.getPackageResources( Engine.class );
  +       ResourceManager.getPackageResources( Engine.class );
   
       //==============================================================
       // state
  @@ -265,8 +265,7 @@
        */
       public EngineClassLoader( ClassLoader parent )
       {
  -        super( new URL[ 0 ], parent );
  -        m_parsable = getParentURLs();
  +        this( new URL[ 0 ], parent );
       }
   
       /**
  @@ -281,19 +280,6 @@
           m_parsable = getParentURLs();
       }
   
  -    /**
  -     * Creation of a new engine with a parent classloader, URL array and URL handler factory.
  -     * @param urls a set of URLs to add to the classloader
  -     * @param parent the parent classloader
  -     * @param handler the URL stream handler factory
  -     */
  -    public EngineClassLoader( URL[] urls, ClassLoader parent, URLStreamHandlerFactory handler )
  -    {
  -        super( new URL[ 0 ], parent, handler );
  -        m_urls = urls;
  -        m_parsable = getParentURLs();
  -    }
  -
       //=======================================================================
       // LogEnabled
       //=======================================================================
  @@ -395,7 +381,7 @@
           }
           else
           {
  -            m_manager = new DefaultApplianceRepository( this );
  +            m_manager = new DefaultApplianceRepository();
           }
   
           if( context.hasEntry( "urn:assembly:threads.manager" ) )
  
  
  
  1.2       +21 -2     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java
  
  Index: AbstractLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/AbstractLifestyleHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractLifestyleHandler.java	13 Mar 2003 01:04:14 -0000	1.1
  +++ AbstractLifestyleHandler.java	10 Apr 2003 04:36:13 -0000	1.2
  @@ -63,6 +63,7 @@
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.meta.info.ReferenceDescriptor;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.ExtensionDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
  @@ -179,11 +180,29 @@
       // LifestyleHandler
       //==============================================================
   
  +    /**
  +     * Resolve a object to a value qualified by a supplied service 
  +     * reference.
  +     *
  +     * @param partition the context within the the resolution is applied
  +     * @param ref the reference descriptor
  +     * @return the resolved object
  +     * @throws ContextException if an error occurs
  +     * @todo build a proxy that isolates the service described by the 
  +     *   ref argument
  +     */
  +    public Object resolve( Object partition, String ref )
  +        throws LocatorException
  +    {
  +        return resolve( partition );
  +    }
  +
      /**
       * Activate a service provided by the appliance.
       * @param appliance the appliance to deploy
       */
  -    public abstract Object resolve( Object partition ) throws LocatorException;
  +    public abstract Object resolve( Object partition ) 
  +        throws LocatorException;
   
      /**
       * Release an a service or handler established by the appliance.  The 
  
  
  
  1.2       +1 -25     avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleHandler.java
  
  Index: LifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly/src/java/org/apache/avalon/assembly/lifestyle/LifestyleHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LifestyleHandler.java	13 Mar 2003 01:04:16 -0000	1.1
  +++ LifestyleHandler.java	10 Apr 2003 04:36:13 -0000	1.2
  @@ -63,30 +63,6 @@
   public interface LifestyleHandler extends Reclaimable
   {
      /**
  -    * Activate of the appliance.
  -    * @return the implementation object
  -    */
  -    //Object access() throws LifestyleException;
  -
  -   /**
  -    * Activate a service provided by the appliance.
  -    * @param appliance the appliance to deploy
  -    */
  -    //Object access( DependencyDescriptor dependency ) throws LifestyleException;
  -
  -   /**
  -    * Activate an extension handler provided by the appliance.
  -    * @param appliance the appliance to deploy
  -    */
  -    //Object access( StageDescriptor stage ) throws LifestyleException;
  -
  -   /**
  -    * Release an a service or handler established by the appliance.
  -    * @param object the service to be released
  -    */
  -    //void release( Object object );
  -
  -   /**
       * Terminate the handler.
       */
       void terminate();
  
  
  
  1.3       +14 -4     avalon-sandbox/merlin/assembly-spi/src/java/org/apache/avalon/assembly/appliance/Appliance.java
  
  Index: Appliance.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly-spi/src/java/org/apache/avalon/assembly/appliance/Appliance.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Appliance.java	17 Mar 2003 02:52:52 -0000	1.2
  +++ Appliance.java	10 Apr 2003 04:36:13 -0000	1.3
  @@ -53,15 +53,16 @@
   import java.util.Map;
   import java.net.URL;
   
  -import org.apache.avalon.framework.parameters.Parameters;
  -import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.assembly.locator.Contextualizable;
   import org.apache.avalon.assembly.locator.Reclaimable;
  +import org.apache.avalon.framework.parameters.Parameters;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.meta.info.ReferenceDescriptor;
   import org.apache.avalon.meta.info.DependencyDescriptor;
   import org.apache.avalon.meta.info.StageDescriptor;
  +import org.apache.avalon.meta.info.Type;
   import org.apache.avalon.meta.model.LoggingDirective;
   import org.apache.avalon.meta.model.ContextDirective;
  -import org.apache.avalon.meta.info.Type;
   
   /**
    * An appliance manages the establishment of a component
  @@ -111,6 +112,15 @@
       * @return the appliance URL
       */
       URL getURL();
  +
  +   /**
  +    * Get the URL for the supplied service reference.
  +    * @param type the service type ref
  +    * @return the service URL
  +    * @exception UnknownServiceException if the supplied reference is unknown 
  +    *   to the appliance.
  +    */
  +    URL getURL( String type ) throws UnknownServiceException;
   
       /**
        * Return the component type backing the appliance.
  
  
  
  1.1                  avalon-sandbox/merlin/assembly-spi/src/java/org/apache/avalon/assembly/appliance/CascadingIOException.java
  
  Index: CascadingIOException.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
      "Apache Software Foundation"  must not be used to endorse or promote
      products derived  from this  software without  prior written
      permission. For written permission, please contact apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.avalon.assembly.appliance;
  
  import java.io.IOException;
  
  /**
   * Exception to indicate that there was a IO exception.
   *
   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
   * @version $Revision: 1.1 $ $Date: 2003/04/10 04:36:13 $
   */
  public class CascadingIOException
      extends IOException
  {
  
       private Throwable m_cause;
  
      /**
       * Construct a new <code>ApplianceException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public CascadingIOException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>ApplianceException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public CascadingIOException( final String message, final Throwable throwable )
      {
          super( message );
          m_cause = throwable;
      }
  
     /**
      * Return the cause of the exception.
      * @return the causal exception
      */
      public Throwable getCause()
      {
          return m_cause;
      }
  }
  
  
  
  
  1.2       +11 -0     avalon-sandbox/merlin/assembly-spi/src/java/org/apache/avalon/assembly/locator/Resolvable.java
  
  Index: Resolvable.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/assembly-spi/src/java/org/apache/avalon/assembly/locator/Resolvable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Resolvable.java	13 Mar 2003 01:04:52 -0000	1.1
  +++ Resolvable.java	10 Apr 2003 04:36:13 -0000	1.2
  @@ -74,4 +74,15 @@
        */
       Object resolve( Object partition )
           throws LocatorException;
  +
  +    /**
  +     * Resolve a object to a value qualified by a supplied service reference.
  +     *
  +     * @param partition the context within the the resolution is applied
  +     * @param ref the service reference
  +     * @return the resolved object
  +     * @throws ContextException if an error occurs
  +     */
  +    Object resolve( Object partition, String ref )
  +        throws LocatorException;
   }
  
  
  
  1.5       +4 -85     avalon-sandbox/merlin/merlin-cli/src/java/Merlin.java
  
  Index: Merlin.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-cli/src/java/Merlin.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Merlin.java	4 Apr 2003 12:16:46 -0000	1.4
  +++ Merlin.java	10 Apr 2003 04:36:14 -0000	1.5
  @@ -78,7 +78,6 @@
    */
   public class Merlin
   {
  -
       //--------------------------------------------------------------------------
       // static
       //--------------------------------------------------------------------------
  @@ -100,9 +99,6 @@
       private static URLClassLoader CLASSLOADER;
       private static URLClassLoader COMMON;
   
  -    //private static File BASE;
  -    //private static File PROFILE;
  -
       private static Options buildCommandLineOptions()
       {
           // create Options object 
  @@ -166,11 +162,10 @@
           options.addOption( locale );
   
           return options;
  -        
       }
   
       //--------------------------------------------------------------------------
  -    // state
  +    // main
       //--------------------------------------------------------------------------
   
      /**
  @@ -276,9 +271,10 @@
               File sys = new File( lib, "system" );
               URL[] targets = getJarFiles( shared );
               URL[] libs = getJarFiles( sys, targets );
  -            ClassLoader current = Thread.currentThread().getContextClassLoader();
  +            ClassLoader current = ClassLoader.getSystemClassLoader();
               COMMON = new URLClassLoader( targets, current );
               CLASSLOADER =  new URLClassLoader( libs, current );
  +            Thread.currentThread().setContextClassLoader( CLASSLOADER );
   
               //
               // build the kernel loader context
  @@ -371,7 +367,6 @@
           // so we can not go ahead with bootstrap classpath construction
           //
   
  -        Thread.currentThread().setContextClassLoader( CLASSLOADER );
           Object kernelLoader = null;
           Class clazz;
   
  @@ -434,7 +429,7 @@
       {
           HelpFormatter formatter = new HelpFormatter();
           final String description = 
  -          "\nDescription: The merlin command executes the deployment of a component block.  The [block] argument may be either an block descriptor file or a jar file containing a block descriptor.  If not value if declared, Merlin will attempt to execute a file named 'block.xml' in the current directory."; 
  +          "\nDescription: The merlin command executes the deployment of a component block.  The [block] argument may be either an block descriptor file or a jar file containing a block descriptor.  If no value if declared, Merlin will attempt to execute a file named 'block.xml' in the current directory."; 
   
           formatter.printHelp( "merlin [block]", description, CL_OPTIONS, "", true );
       }
  @@ -512,83 +507,7 @@
               }
           }
       }
  -/* NEVER USED
  -    private static File getBlockPath( File system, File home, CommandLine command ) throws IOException
  -    {
  -        boolean flag = false;
  -        String filename = null;
  -        final String key = "block";
  -        if( command.hasOption( key ) )
  -        {
  -            filename = command.getOptionValue( key );
  -        }
  -        else
  -        {
  -            // check if there is a file in the current directory called block.xml
  -            // and if so, we will use that as the deployment scanario
  -
  -            filename = "block.xml";
  -            File local = getFile( HOME, "block.xml" );
  -            if( local.exists() )
  -            {
  -                //
  -                // the current directory is equivalent to the info directory
  -                // so the base directory is the parent of the current directory
  -                
  -                return local.getParentFile();
  -            }
  -        }
  -
  -        //
  -        // if the filename is a jar file then return the filename as a URL
  -        //
  -
  -        boolean resolved = false;
  -        File file = getFile( HOME, filename );
  -        if( file.exists() )
  -        {
  -            return file;
  -        }
   
  -        final String error =
  -           "Unable to locate a block defintion relative to the paths: " + file;
  -        throw new IllegalArgumentException( error );
  -    }
  -*/
  -/* NEVER USED
  -    private static File getProfile( File home, CommandLine command ) throws IOException
  -    {
  -        boolean flag = false;
  -        String filename = null;
  -        final String key = "profile"; 
  -        if( command.hasOption( key ) )
  -        {
  -            filename = command.getOptionValue( key );
  -        }
  -        else
  -        {
  -            flag = true;
  -            filename = "profile.xml";
  -        }
  -
  -        try
  -        {
  -            File file = getFile( home, filename );
  -            if( !file.isFile() )
  -            {
  -                final String error = 
  -                  "Supplied profile argument does not refer to a file: " + file;
  -            }
  -            return file;
  -        }
  -        catch( FileNotFoundException fnfe )
  -        {
  -            String error =
  -              "Could not locate profile: " + filename + " is the home directory: " + home;
  -            throw new FileNotFoundException( error );
  -        }
  -    }
  -*/
      /**
       * Return the directory to be used as the working home directory.  If no command line 
       * argument is supplied, the home directory defaults to the directory derived from 
  
  
  
  1.5       +0 -7      avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/DefaultBlock.java
  
  Index: DefaultBlock.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-core/src/java/org/apache/avalon/merlin/block/impl/DefaultBlock.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultBlock.java	31 Mar 2003 18:52:22 -0000	1.4
  +++ DefaultBlock.java	10 Apr 2003 04:36:14 -0000	1.5
  @@ -152,13 +152,6 @@
       private Appliance[] m_shutdown;
   
      /**
  -    * List of the commonents that have been established explicity by the 
  -    * block during deployment.
  -    */
  -    // NEVER USED!
  -    //private Map m_components = new Hashtable();
  -
  -   /**
       * Flag holding the deoplyed state of the block.
       */ 
       private boolean m_deployed = false;
  
  
  
  1.4       +2 -1      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultKernel.java	6 Apr 2003 19:24:52 -0000	1.3
  +++ DefaultKernel.java	10 Apr 2003 04:36:14 -0000	1.4
  @@ -471,6 +471,7 @@
           {
               Configuration engine = m_config.getChild( "engine" );
               m_engine = bootstrapEngine( m_logging, m_pool, engine, m_loader );
  +            Thread.currentThread().setContextClassLoader( m_engine );
           }
           catch( Throwable e )
           {
  
  
  
  1.3       +1 -0      avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/conf/block.xml
  
  Index: block.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/conf/block.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- block.xml	7 Apr 2003 17:02:06 -0000	1.2
  +++ block.xml	10 Apr 2003 04:36:14 -0000	1.3
  @@ -6,5 +6,6 @@
            <name>Apache Financial Services</name>
          </configuration>
        </component>
  +     <component name="simulator" class="org.apache.bank.impl.ActionSimulator" activation="startup"/>
     </container>
   </block>
  
  
  
  1.2       +21 -0     avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/java/org/apache/bank/impl/Accounts.java
  
  Index: Accounts.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/java/org/apache/bank/impl/Accounts.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Accounts.java	6 Apr 2003 19:22:37 -0000	1.1
  +++ Accounts.java	10 Apr 2003 04:36:14 -0000	1.2
  @@ -65,6 +65,8 @@
   {
       private int m_index = 0;
   
  +    private String m_name;
  +
      /**
       * Internal list of accounts.
       */
  @@ -74,6 +76,25 @@
       * Internal list of removed accounts.
       */
       private Hashtable m_archive = new Hashtable();
  +
  +    public Accounts()
  +    {
  +        // serializable version
  +    }
  +
  +    public Accounts( String name )
  +    {
  +        m_name = name;
  +    }
  +
  +   /**
  +    * Get the name of the bank.
  +    * @return the bank name
  +    */
  +    public String getName()
  +    {
  +        return m_name;
  +    }
   
      /**
       * Create, register and return a new account.
  
  
  
  1.3       +1 -1      avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/java/org/apache/bank/impl/BankProvider.java
  
  Index: BankProvider.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/java/org/apache/bank/impl/BankProvider.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BankProvider.java	7 Apr 2003 17:02:06 -0000	1.2
  +++ BankProvider.java	10 Apr 2003 04:36:14 -0000	1.3
  @@ -124,7 +124,7 @@
           else
           {
               getLogger().info( "creating new account registry" );
  -            m_accounts = new Accounts();
  +            m_accounts = new Accounts( m_name );
           }
       }
   
  
  
  
  1.2       +3 -0      avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/java/org/apache/bank/impl/BankProvider.xinfo
  
  Index: BankProvider.xinfo
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/java/org/apache/bank/impl/BankProvider.xinfo,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BankProvider.xinfo	6 Apr 2003 19:22:37 -0000	1.1
  +++ BankProvider.xinfo	10 Apr 2003 04:36:14 -0000	1.2
  @@ -7,4 +7,7 @@
       <name>bank</name>
       <version>1.0</version>
     </info>
  +  <services>
  +    <service type="org.apache.bank.Bank"/>
  +  </services>
   </type>
  
  
  
  1.2       +31 -48    avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/test/org/apache/bank/BankTestCase.java
  
  Index: BankTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/test/org/apache/bank/BankTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BankTestCase.java	6 Apr 2003 19:22:37 -0000	1.1
  +++ BankTestCase.java	10 Apr 2003 04:36:14 -0000	1.2
  @@ -23,6 +23,7 @@
   import java.net.MalformedURLException;
   import java.net.JarURLConnection;
   
  +import org.apache.AbstractTestCase;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  @@ -30,19 +31,19 @@
   import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.context.ContextException;
  +import org.apache.avalon.meta.info.ReferenceDescriptor;
   import org.apache.avalon.merlin.block.Block;
  -import org.apache.avalon.merlin.kernel.impl.DefaultKernel;
   import org.apache.avalon.merlin.kernel.KernelException;
   import org.apache.avalon.assembly.util.ExceptionHelper;
   import org.apache.avalon.assembly.locator.DefaultLocator;
   import org.apache.avalon.assembly.appliance.Appliance;
  +import org.apache.avalon.assembly.appliance.block.Handler;
  +import org.apache.avalon.assembly.util.ExceptionHelper;
   import junit.framework.TestCase;
   
  -public class BankTestCase extends TestCase
  +public class BankTestCase extends AbstractTestCase
   {
   
  -    private DefaultKernel m_kernel;
  -
       public BankTestCase( )
       {
           this( "bank" );
  @@ -53,45 +54,32 @@
           super( name );
       }
   
  -    public void setUp() throws Exception
  -    {
  -        ClassLoader loader = Thread.currentThread().getContextClassLoader();
  -        File base = new File( System.getProperty( "user.dir" ) );
  -        File classes = new File( base, "target/classes" );
  -
  -        DefaultLocator context = new DefaultLocator();
  -        context.put( "urn:merlin:home", base );
  -        context.put( "urn:merlin:system", base );
  -        context.put( "urn:merlin:classloader.common", loader );
  -        context.put( "urn:merlin:classloader.system", loader );
  -        context.put( "urn:merlin:debug", "WARN" );
  -        context.put( "urn:merlin:logging.priority", "INFO" );
  -        context.put( "urn:merlin:block.url", classes.toURL() );
  -        context.makeReadOnly();
  -
  -        m_kernel = new DefaultKernel();
  -        m_kernel.contextualize( context );
  -        m_kernel.initialize();
  -    }
  -
       public void testBank() throws Exception
       {
  -        if( m_kernel != null )
  +        Bank bank = null;
  +        try
           {
  -            //
  -            // get the bank
  -            //
  -
  -            Block block = m_kernel.getRootBlock();
  -            URL banking = block.getURL();
  -            URL url = new URL( banking, banking.getPath() + "bank" );
  -            Appliance manager = (Appliance) url.getContent();
  -            Bank bank = (Bank) manager.resolve( this );
  +            URL root = (URL) super.getRootBlock().getURL();
  +            URL url = new URL( root, "/banking/bank");
  +            URL service = new URL( url, "#org.apache.bank.Bank" );
  +            System.out.println( "URL: " + service );
  +            bank = (Bank) service.getContent();
  +        }
  +        catch( Throwable e )
  +        {
  +            final String msg = "Bank establishment failure.";
  +            final String error = ExceptionHelper.packException( msg, e );
  +            System.out.println( error );
  +            assertTrue( false );
  +            return;
  +        }
   
  -            //
  -            // create an account and deposit some funds
  -            //
  +        //
  +        // create an account and deposit some funds
  +        //
               
  +        try
  +        {
               Account account = bank.createAccount( "test" );
               float deposit = new Float( 100.20 ).floatValue();
               account.deposit( deposit );
  @@ -113,18 +101,13 @@
               bank.closeAccount( account.getID() );
               assertTrue( true );
           }
  -        else
  +        catch( Throwable e )
           {
  +            final String msg = "Bank runtime failure.";
  +            final String error = ExceptionHelper.packException( msg, e );
  +            System.out.println( error );
               assertTrue( false );
  -        }
  -    }
  -
  -
  -    public void tearDown() throws Exception
  -    {
  -        if( m_kernel != null )
  -        { 
  -            m_kernel.shutdown();
  +            return;
           }
       }
   }
  
  
  
  1.2       +1 -12     avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/maven.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- maven.xml	7 Apr 2003 16:59:27 -0000	1.1
  +++ maven.xml	10 Apr 2003 04:36:14 -0000	1.2
  @@ -1,14 +1,3 @@
  -<project default="java:jar" xmlns:maven="jelly:maven" xmlns:j="jelly:core" xmlns:util="jelly:util">
  -
  -  <!--
  -  <preGoal name="war:war">
  -    <mkDir dir="${basedir}/target/classes/WEB-INF/lib"/>
  -    <j:forEach var="dependency" items="${pom.dependencies}">
  -      <copy 
  -        todir="${basedir}/target/classes/WEB-INF/lib"
  -        file="${maven.repo.local}/${dependency.artifactDirectory}/jars/${dependency.artifact}"/>
  -    </j:forEach>
  -  </preGoal>
  -  -->
  +<project default="war:war" xmlns:maven="jelly:maven" xmlns:j="jelly:core" xmlns:util="jelly:util">
   
   </project>
  
  
  
  1.2       +4 -5      avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/src/java/org/apache/bank/SimpleServlet.java
  
  Index: SimpleServlet.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/src/java/org/apache/bank/SimpleServlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleServlet.java	7 Apr 2003 16:59:27 -0000	1.1
  +++ SimpleServlet.java	10 Apr 2003 04:36:14 -0000	1.2
  @@ -86,11 +86,10 @@
               // get the bank
               //
   
  -            Block block = super.getRootBlock();
  -            URL banking = block.getURL();
  -            URL url = new URL( banking, banking.getPath() + "bank" );
  -            Appliance manager = (Appliance) url.getContent();
  -            m_bank = (Bank) manager.resolve( this );
  +            URL root = getRootBlock().getURL();
  +            URL url = new URL( root, "/banking/bank" );
  +            URL service = new URL( url, "#org.apache.bank.Bank" );
  +            m_bank = (Bank) service.getContent();
   
               log( "Bank established: " + m_bank );
   
  
  
  
  1.8       +1 -1      avalon-sandbox/merlin/merlin-smp/xdocs/tools/navigation.xml
  
  Index: navigation.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/merlin-smp/xdocs/tools/navigation.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- navigation.xml	8 Apr 2003 13:06:08 -0000	1.7
  +++ navigation.xml	10 Apr 2003 04:36:14 -0000	1.8
  @@ -12,7 +12,7 @@
   
       <menu name="About Merlin">
         <item name="Overview" href="/about/index.html"/>
  -      <item name="Getting Started" href="/starting/index.html">
  +      <item name="Getting Started" href="/starting/index.html"/>
         <item name="Merlin System" href="/merlin/index.html"/>
         <item name="Meta Model" href="/meta/index.html"/>
         <item name="Tools" href="/tools/index.html">
  
  
  
  1.3       +15 -5     avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/info/ReferenceDescriptor.java
  
  Index: ReferenceDescriptor.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/info/ReferenceDescriptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ReferenceDescriptor.java	29 Mar 2003 03:25:58 -0000	1.2
  +++ ReferenceDescriptor.java	10 Apr 2003 04:36:14 -0000	1.3
  @@ -77,14 +77,24 @@
       private final Version m_version;
   
       /**
  -     * Construct a service with specified classname.
  +     * Construct a service with specified type.
        *
  -     * @param classname the name of the service
  +     * @param type the service type spec
        * @exception NullPointerException if the classname is null
        */
  -    public ReferenceDescriptor( final String classname ) throws NullPointerException
  +    public ReferenceDescriptor( final String type ) throws NullPointerException
       {
  -        this( classname, Version.getVersion( "1.0" ) );
  +        int index = type.indexOf(":");
  +        if( index > -1 )
  +        {
  +            m_classname = type.substring( 0, index );
  +            m_version = Version.getVersion( type.substring( index + 1 ) );
  +        }
  +        else
  +        {
  +            m_classname = type;
  +            m_version = Version.getVersion( "1.0.0" );
  +        }
       }
   
       /**
  
  
  

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


Mime
View raw message