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 2002/09/27 13:13:34 UTC

cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground BasicComponent.java BasicComponent.xinfo SimpleComponent.xinfo

mcconnell    2002/09/27 04:13:34

  Modified:    assembly build.xml default.properties
               assembly/src/java/org/apache/excalibur/merlin
                        ExceptionHelper.java Main.java
               assembly/src/java/org/apache/excalibur/merlin/assembly
                        DependencyGraph.java TypeManager.java
               assembly/src/java/org/apache/excalibur/merlin/kernel
                        DefaultKernel.java
               assembly/src/java/org/apache/excalibur/merlin/model
                        Profile.java Resource.java
               assembly/src/java/org/apache/excalibur/merlin/model/verifier
                        MetaDataVerifier.java
               assembly/src/java/org/apache/excalibur/merlin/resource
                        AbstractLifestyleHandler.java DefaultManager.java
                        DefaultResource.java DeploymentHelper.java
                        LifecycleHelper.java
               assembly/src/java/org/apache/excalibur/merlin/service
                        DefaultRegistry.java Handler.java
                        ServiceLocator.java ServicePublisher.java
                        ServiceURLConnection.java ServiceURLFactory.java
                        UnknownServiceException.java
               assembly/src/java/org/apache/excalibur/playground
                        BasicComponent.java BasicComponent.xinfo
                        SimpleComponent.xinfo
  Added:       assembly/src/java/org/apache/excalibur/merlin/model
                        ServiceAccessPoint.java
               assembly/src/java/org/apache/excalibur/merlin/resource
                        DefaultServiceAccessPoint.java
  Log:
  Updates including introduction of service access pont holders for remote
  activation - content is early and subject to change.
  
  Revision  Changes    Path
  1.67      +1 -0      jakarta-avalon-excalibur/assembly/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/build.xml,v
  retrieving revision 1.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- build.xml	15 Sep 2002 02:25:36 -0000	1.66
  +++ build.xml	27 Sep 2002 11:13:32 -0000	1.67
  @@ -22,6 +22,7 @@
       <pathelement location="${build.classes}"/>
       <pathelement location="${checkstyle.jar}"/>
       <pathelement location="${xml-apis.jar}"/>
  +    <pathelement location="${servlet.jar}"/>
       <pathelement path="${java.class.path}"/>
     </path>
   
  
  
  
  1.17      +7 -2      jakarta-avalon-excalibur/assembly/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/default.properties,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- default.properties	15 Sep 2002 02:25:36 -0000	1.16
  +++ default.properties	27 Sep 2002 11:13:32 -0000	1.17
  @@ -82,6 +82,11 @@
   logkit.lib=${logkit.home}/build/lib
   logkit.jar=${logkit.lib}/logkit.jar
   
  +# ----- Servlet -----
  +servlet.home=${basedir}
  +servlet.lib=${servlet.home}/lib
  +servlet.jar=${servlet.lib}/servlet.jar
  +
   # --------------------------------------------------
   
   #  Settings used to configure compile environment
  @@ -143,8 +148,8 @@
   demo.jar = ${demo.name}.jar
   sar.name = ${name}-${version}.sar
   
  -activation.version = 1.0
  -activation.jar = ${name}-activation-${activation.version}.jar
  +#activation.version = 1.0
  +#activation.jar = ${name}-activation-${activation.version}.jar
   
   # avalon apps reference
   excalibur.dir = ./..
  
  
  
  1.4       +2 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/ExceptionHelper.java
  
  Index: ExceptionHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/ExceptionHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ExceptionHelper.java	10 Sep 2002 23:07:20 -0000	1.3
  +++ ExceptionHelper.java	27 Sep 2002 11:13:32 -0000	1.4
  @@ -92,7 +92,8 @@
               out.println( "===================================================================" );
               if( trace ) 
               {
  -                e.printStackTrace();
  +                Throwable root = getLastThrowable( e );
  +                root.printStackTrace();
                   out.println( "===================================================================" );
               }
           }
  
  
  
  1.20      +3 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Main.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Main.java	16 Sep 2002 21:42:42 -0000	1.19
  +++ Main.java	27 Sep 2002 11:13:32 -0000	1.20
  @@ -155,6 +155,8 @@
           {
               final String error = "Controller deployment failure.";
               ExceptionHelper.printException( error, e, null, true );
  +            //String message = ExceptionHelper.packException( error, e );
  +            //System.err.println( message );
               controller.dispose();
           }
       }
  
  
  
  1.6       +3 -3      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DependencyGraph.java
  
  Index: DependencyGraph.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DependencyGraph.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DependencyGraph.java	22 Aug 2002 06:27:33 -0000	1.5
  +++ DependencyGraph.java	27 Sep 2002 11:13:32 -0000	1.6
  @@ -261,7 +261,7 @@
           // support to the subject profile
           //
   
  -        final StageDescriptor[] phases = profile.getType().getPhases();
  +        final StageDescriptor[] phases = profile.getType().getStages();
           for( int i=(phases.length-1); i>-1; i-- )
           {
               StageDescriptor phase = phases[i];
  @@ -344,7 +344,7 @@
               // as an extension provider
               //
   
  -            final StageDescriptor[] phases = other.getType().getPhases();
  +            final StageDescriptor[] phases = other.getType().getStages();
               for( int j = 0; j < phases.length; j++ )
               {
                    Profile extension = other.getExtensionProfile( phases[j] );
  
  
  
  1.22      +82 -2     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java
  
  Index: TypeManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- TypeManager.java	12 Sep 2002 08:30:04 -0000	1.21
  +++ TypeManager.java	27 Sep 2002 11:13:33 -0000	1.22
  @@ -39,6 +39,7 @@
   import org.apache.avalon.excalibur.packagemanager.impl.DefaultExtensionManager;
   import org.apache.excalibur.meta.info.Type;
   import org.apache.excalibur.meta.info.ReferenceDescriptor;
  +import org.apache.excalibur.meta.info.ServiceDefinition;
   import org.apache.excalibur.merlin.model.IncludeDescriptor;
   import org.apache.excalibur.merlin.model.LibraryDescriptor;
   import org.apache.excalibur.merlin.model.ClasspathDescriptor;
  @@ -477,7 +478,7 @@
               }
               catch( Throwable error )
               {
  -                getLocalLogger().warn(
  +                getLogger().warn(
                     "Encountered error while loading resource: " 
                     + file, error );
                   errors.put( file, error );
  @@ -592,6 +593,85 @@
       boolean isLocal( String classname )
       {
           return m_types.isLocal( classname );
  +    }
  +
  +   /**
  +    * Resolve a {@link ServiceDefinition} from a classname.
  +    *
  +    * @param classname the service type
  +    * @return the service descriptor
  +    * @exception TypeException if the type is unknown
  +    */
  +    public ServiceDefinition getService( ReferenceDescriptor reference ) throws TypeException
  +    {
  +        ServiceDefinition definition = m_services.getService( reference );
  +        if( definition != null )
  +        {
  +            return definition;
  +        }
  +        else
  +        {
  +
  +            //
  +            // try to construct the service type 
  +            //
  +
  +            try
  +            {
  +                definition = m_services.addService( reference.getClassname() );
  +                if( definition.matches( reference ) )
  +                {
  +                    return definition;
  +                }
  +                throw new Exception();
  +            }
  +            catch( Throwable e )
  +            {
  +                //
  +                // otherwise try to locate the service from the parent classloader
  +                //
  +
  +                ClassLoader parent = getParent();
  +                if( parent instanceof TypeManager )
  +                {
  +                    return ((TypeManager)parent).getService( reference );
  +                }
  +                else
  +                {
  +                    throw new TypeException(
  +                      "Service definition unknown, classname: " + reference );
  +                }
  +            }
  +        }
  +    }
  +
  +   /**
  +    * Returns the set of local service types know to the registry.
  +    * @return the set of service types registered with the registry
  +    */
  +    protected ServiceDefinition[] getServices()
  +    {
  +        return m_services.getServices();
  +    }
  +
  +   /**
  +    * Returns the set of service types know to the registry that are capable of 
  +    * supporting the supplied reference.
  +    * @param reference the service descriptor reference 
  +    * @return the set of candidate component types
  +    */
  +    //public ServiceDefinition getService( ReferenceDescriptor reference )
  +    //{
  +    //    return m_services.getService( reference );
  +    //}
  +
  +   /**
  +    * Test if a service class is locally managed.
  +    * @return TRUE if the class is local to this manager
  +    */
  +    boolean isLocalService( String classname )
  +    {
  +        return m_services.isLocal( classname );
       }
   
       //================================================================================
  
  
  
  1.52      +1 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.java
  
  Index: DefaultKernel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- DefaultKernel.java	9 Sep 2002 13:34:50 -0000	1.51
  +++ DefaultKernel.java	27 Sep 2002 11:13:33 -0000	1.52
  @@ -46,7 +46,6 @@
   import org.apache.excalibur.merlin.model.Profile;
   import org.apache.excalibur.merlin.model.Resource;
   import org.apache.excalibur.merlin.container.ContainerResource;
  -import org.apache.excalibur.merlin.service.ServiceURLFactory;
   import org.apache.excalibur.merlin.resource.LifestyleManager;
   import org.apache.excalibur.merlin.resource.DefaultLifestyleManager;
   import org.apache.excalibur.merlin.service.Registry;
  
  
  
  1.26      +13 -5     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Profile.java
  
  Index: Profile.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Profile.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Profile.java	31 Aug 2002 14:54:00 -0000	1.25
  +++ Profile.java	27 Sep 2002 11:13:33 -0000	1.26
  @@ -12,6 +12,7 @@
   import java.util.Hashtable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.excalibur.meta.ConfigurationBuilder;
   import org.apache.excalibur.meta.info.Type;
  @@ -268,13 +269,13 @@
   
           if( null == name )
           {
  -            m_name = type.getInfo().getName() + "#" + System.identityHashCode( this );
  +            m_name = type.getInfo().getName() + "-" + System.identityHashCode( this );
           }
           else
           {
               if( mode != EXPLICIT )
               {
  -               m_name = name + "#" + System.identityHashCode( this ); 
  +               m_name = name + "-" + System.identityHashCode( this ); 
               }
               else
               {
  @@ -406,6 +407,13 @@
               return m_config;
           }
   
  +        final Class type = classloader.loadClass( 
  +          getType().getInfo().getImplementationKey() );
  +        if( !Configurable.class.isAssignableFrom( type ) )
  +        {
  +            return null;
  +        }
  +
           final Configuration defaults = getType().getConfiguration( classloader );
           Configuration base = null;
           if( getConfiguration().getAttribute("src", null ) != null )
  @@ -477,7 +485,7 @@
       }
   
      /**
  -    * Add an association for a service dependecy.
  +    * Add an association for a service dependency.
       * @param role the role against which the supplied resource is to be associated
       * @param resource the resource that will fulfill the provider dependency
       * @return an association binding the role and provider within the scope of the 
  @@ -587,7 +595,7 @@
           return buffer.toString();
       }
   
  -    private String modeToString( int mode )
  +    public static String modeToString( int mode )
       {
           if( mode == IMPLICIT )
           {
  
  
  
  1.8       +18 -1     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Resource.java
  
  Index: Resource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Resource.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Resource.java	23 Aug 2002 06:25:13 -0000	1.7
  +++ Resource.java	27 Sep 2002 11:13:33 -0000	1.8
  @@ -7,6 +7,9 @@
    */
   package org.apache.excalibur.merlin.model;
   
  +import java.net.URL;
  +
  +import org.apache.excalibur.meta.info.ReferenceDescriptor;
   import org.apache.excalibur.meta.info.ServiceDescriptor;
   import org.apache.avalon.framework.activity.Disposable;
   
  @@ -27,6 +30,13 @@
       String getPath();
   
       /**
  +     * Returns a URL to the resource.
  +     *
  +     * @return the resource URL
  +     */
  +    URL getURL();
  +
  +    /**
        * Returns the component class.
        *
        * @return the class
  @@ -39,6 +49,13 @@
        * @return the descriptor
        */
       ServiceDescriptor[] getServices();
  +
  +    /**
  +     * Returns a service access point for the supplied reference.
  +     * @param reference a reference to a service type
  +     * @return the service definition
  +     */
  +    public ServiceAccessPoint getServiceAccessPoint( ReferenceDescriptor reference );
   
       /**
        * Return the profile.
  
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/ServiceAccessPoint.java
  
  Index: ServiceAccessPoint.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.merlin.model;
  
  import org.apache.excalibur.meta.info.ServiceDefinition;
  import org.apache.excalibur.meta.info.ServiceDescriptor;
  
  /**
   * Interface through which the service descriptor of a service can 
   * be accessed by a client.
   *
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2002/09/27 11:13:33 $
   */
  public interface ServiceAccessPoint
  {
  
     /**
      * Returns the {@link ServiceDescriptor} for this service.
      *
      * @return the service descriptor.
      */
      ServiceDescriptor getServiceDescriptor();
  
     /**
      * Returns the {@link ServiceDefinition} for this service.
      *
      * @return the service definition.
      */
      ServiceDefinition getServiceDefinition();
  
      /**
       * Return the resource instance.
       *
       * @return an instance of the type defined by the profile
       * @exception Exception if an access error occurs
       */
      Object access() throws Exception;
  
      /**
       * Release the service instance.
       * @param instance the instance to release
       */
      void release( Object instance );
  
  }
  
  
  
  
  1.8       +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/verifier/MetaDataVerifier.java
  
  Index: MetaDataVerifier.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/verifier/MetaDataVerifier.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MetaDataVerifier.java	15 Sep 2002 00:19:36 -0000	1.7
  +++ MetaDataVerifier.java	27 Sep 2002 11:13:33 -0000	1.8
  @@ -120,7 +120,7 @@
                                  clazz.getClassLoader() );
           final Class[] phases =
               getPhaseClasses( name,
  -                               profile.getType().getPhases(),
  +                               profile.getType().getStages(),
                                  clazz.getClassLoader() );
   
           m_verifier.verifyType( name, clazz, interfaces, phases );
  
  
  
  1.11      +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/AbstractLifestyleHandler.java
  
  Index: AbstractLifestyleHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/AbstractLifestyleHandler.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AbstractLifestyleHandler.java	10 Sep 2002 23:07:21 -0000	1.10
  +++ AbstractLifestyleHandler.java	27 Sep 2002 11:13:33 -0000	1.11
  @@ -181,7 +181,7 @@
        */
        protected void processAccessStage( Object object ) throws Exception
        {
  -        StageDescriptor[] phases = m_profile.getType().getPhases();
  +        StageDescriptor[] phases = m_profile.getType().getStages();
           for( int i=0; i<phases.length; i++ )
           {
               StageDescriptor stage = phases[i];
  @@ -196,7 +196,7 @@
        */
        protected void processReleaseStage( Object object )
        {
  -        StageDescriptor[] phases = m_profile.getType().getPhases();
  +        StageDescriptor[] phases = m_profile.getType().getStages();
           for( int i=(phases.length-1); i>-1; i-- )
           {
               StageDescriptor stage = phases[i];
  
  
  
  1.6       +3 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultManager.java
  
  Index: DefaultManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultManager.java	15 Sep 2002 00:19:37 -0000	1.5
  +++ DefaultManager.java	27 Sep 2002 11:13:33 -0000	1.6
  @@ -79,8 +79,9 @@
           }
           catch( Throwable e )
           {
  -            final String error = "Unexpected exception while resolving the service from " 
  -              + holder.getResource().getPath() + " for the role: " + role;
  +            final String error = 
  +              "Unexpected exception while resolving the service from profile:" 
  +              + holder.getResource().getProfile().getName() + ", for the role: " + role;
               throw new ResourceException( error, e );
           }
       }
  
  
  
  1.9       +56 -2     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultResource.java
  
  Index: DefaultResource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultResource.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultResource.java	31 Aug 2002 14:54:00 -0000	1.8
  +++ DefaultResource.java	27 Sep 2002 11:13:33 -0000	1.9
  @@ -7,12 +7,17 @@
    */
   package org.apache.excalibur.merlin.resource;
   
  +import java.net.URL;
  +
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.excalibur.merlin.model.Profile;
  +import org.apache.excalibur.merlin.model.ServiceAccessPoint;
   import org.apache.excalibur.merlin.model.Resource;
  +import org.apache.excalibur.meta.info.ReferenceDescriptor;
   import org.apache.excalibur.meta.info.ServiceDescriptor;
  +import org.apache.excalibur.meta.info.ServiceDefinition;
   import org.apache.excalibur.merlin.assembly.ContainerManager;
   
   
  @@ -31,7 +36,7 @@
      /**
       * Resource path header element.
       */
  -    public static final String HEADER = "service:";
  +    public static final String HEADER = "native:";
   
       //==========================================================================
       // state
  @@ -57,6 +62,12 @@
        */
       private final LifestyleHandler m_handler;
   
  +    /**
  +     * The resource URL
  +     */
  +    private final URL m_url;
  +
  +
       //==========================================================================
       // constructor
       //==========================================================================
  @@ -99,6 +110,17 @@
           m_context = context;
           m_handler = handler;
   
  +        try
  +        {
  +            m_url = new URL( HEADER 
  +              + m_manager.getPath() 
  +              + "/" + m_profile.getName() );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = "Cannot construct URL.";
  +            throw new ResourceRuntimeException( error, e );
  +        }
       }
   
       //==========================================================================
  @@ -109,6 +131,7 @@
        * Returns the path of the resource.
        *
        * @return the symbolic path of the resource
  +     * @deprecated
        */
       public String getPath()
       {
  @@ -116,6 +139,16 @@
       }
   
       /**
  +     * Returns a URL to the resource.
  +     *
  +     * @return the resource URL
  +     */
  +    public URL getURL()
  +    {
  +        return m_url;
  +    }
  +
  +    /**
        * Returns the component class.
        *
        * @return the class
  @@ -133,6 +166,27 @@
       public ServiceDescriptor[] getServices()
       {
           return m_profile.getType().getServices();
  +    }
  +
  +    /**
  +     * Returns a service access point for the supplied reference.
  +     * @param reference a reference to a service type
  +     * @return the service definition
  +     */
  +    public ServiceAccessPoint getServiceAccessPoint( ReferenceDescriptor reference )
  +    {
  +        try
  +        {
  +            ServiceDefinition def = m_manager.getService( reference );
  +            ServiceDescriptor des = m_profile.getType().getService( reference );
  +            return new DefaultServiceAccessPoint( this, des, def );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Unable to resolve service access point for reference: " + reference;
  +            throw new ResourceRuntimeException( error, e );
  +        }
       }
   
       /**
  
  
  
  1.10      +1 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DeploymentHelper.java
  
  Index: DeploymentHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DeploymentHelper.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DeploymentHelper.java	15 Sep 2002 00:19:37 -0000	1.9
  +++ DeploymentHelper.java	27 Sep 2002 11:13:33 -0000	1.10
  @@ -229,7 +229,7 @@
           //
   
           Hashtable table = new Hashtable();
  -        StageDescriptor[] stages = profile.getType().getPhases();
  +        StageDescriptor[] stages = profile.getType().getStages();
           for( int i=0; i<stages.length; i++ )
           {
               StageDescriptor stage = stages[i];
  
  
  
  1.12      +1 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/LifecycleHelper.java
  
  Index: LifecycleHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/LifecycleHelper.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- LifecycleHelper.java	12 Sep 2002 11:05:52 -0000	1.11
  +++ LifecycleHelper.java	27 Sep 2002 11:13:33 -0000	1.12
  @@ -282,7 +282,7 @@
   
       private void handleStageExtensions( Profile profile, ResourceProvider provider, Object object, boolean create ) throws Exception
       {
  -        StageDescriptor[] stages = profile.getType().getPhases();
  +        StageDescriptor[] stages = profile.getType().getStages();
           for( int i=0; i<stages.length; i++ )
           {
               StageDescriptor stage = stages[i];
  
  
  
  1.1                  jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/resource/DefaultServiceAccessPoint.java
  
  Index: DefaultServiceAccessPoint.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.excalibur.merlin.resource;
  
  import org.apache.excalibur.meta.info.ServiceDescriptor;
  import org.apache.excalibur.meta.info.ServiceDefinition;
  import org.apache.excalibur.merlin.model.Resource;
  import org.apache.excalibur.merlin.model.ServiceAccessPoint;
  
  /**
   * Interface through which the service descriptor of a service can 
   * be accessed by a client.
   *
   * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
   * @version $Revision: 1.1 $ $Date: 2002/09/27 11:13:33 $
   */
  public class DefaultServiceAccessPoint implements ServiceAccessPoint
  {
      private Resource m_resource;
  
      private ServiceDescriptor m_descriptor;
  
      private ServiceDefinition m_definition;
  
     /**
      * Creation of a new service access point.
      * @param resource the resolurce holding the service implementation
      * @param descriptor the service descriptor
      * @param definition the service defintion
      */
      public DefaultServiceAccessPoint( 
                    Resource resource, 
                    ServiceDescriptor descriptor, 
                    ServiceDefinition definition )
      {
          m_resource = resource;
          m_descriptor = descriptor;
          m_definition = definition;
      }
  
     /**
      * Returns the {@link ServiceDescriptor} for this service.
      *
      * @return the service descriptor.
      */
      public ServiceDescriptor getServiceDescriptor()
      {
          return m_descriptor;
      }
  
     /**
      * Returns the {@link ServiceDefinition} for this service.
      *
      * @return the service definition.
      */
      public ServiceDefinition getServiceDefinition()
      {
          return m_definition;
      }
  
      /**
       * Return the resource instance.
       *
       * @return an instance of the type defined by the profile
       * @exception Exception if an access error occurs
       */
      public Object access() throws Exception
      {
          return m_resource.access();
      }
  
      /**
       * Release the service instance.
       * @param instance the instance to release
       */
      public void release( Object instance )
      {
          m_resource.release( instance );
      }
  
  }
  
  
  
  
  1.6       +186 -5    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/DefaultRegistry.java
  
  Index: DefaultRegistry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/DefaultRegistry.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultRegistry.java	16 Sep 2002 23:17:05 -0000	1.5
  +++ DefaultRegistry.java	27 Sep 2002 11:13:33 -0000	1.6
  @@ -80,7 +80,7 @@
               // handler is already registered
           }
   
  -        m_base = new URL("service", domain, -1, "/");
  +        m_base = new URL("native", domain, -1, "/");
       }
   
      /**
  @@ -206,15 +206,70 @@
       }
   
      /**
  +    * Resolves an object relative to the supplied URL.
  +    *
  +    * @param url the URL
  +    * @exception Exception is an error occurs
  +    */
  +    public Object resolve( URL url ) throws Exception
  +    {
  +        String uri = normalize( url );
  +        if( uri.equals("") )
  +        {
  +            return this;
  +        }
  +        if( uri.indexOf("/") > -1 )
  +        {
  +            String name = uri.substring( 0, uri.indexOf("/") );
  +            Registry child = (Registry) m_table.get( name );
  +            if( child != null )
  +            {
  +                return child.resolve( url );
  +            }
  +            else
  +            {
  +                final String error = "Invalid path element: " + name;
  +                throw new InvalidPathException( uri, error );
  +            }
  +        }
  +        else
  +        {
  +            //
  +            // its an immediate resource
  +            //
  +
  +            Object child = m_table.get( uri );
  +            if( child != null )
  +            {
  +                return child;
  +            }
  +
  +            Resource resource = (Resource) m_resources.get( uri );
  +            if( resource != null )
  +            {
  +                return resource;
  +            }
  +        }
  +        final String error = "Could not locate the requested service.";
  +        throw new UnknownServiceException( uri, error );
  +    }
  +
  +   /**
       * Select a set of service based on a supplied filter.  A filter is 
       * supplied in the form of a URI String.  Interpritation relative to URI path, query,
       * and fragment are protocol dependent.
       *
  -    * @param uri the service uri
  +    * @param path the service uri
       * @exception Exception is an install error occurs
       */
  -    public Resource locate( String uri ) throws UnknownServiceException, InvalidPathException
  +    public Resource locate( String path ) throws UnknownServiceException, InvalidPathException
       {
  +        if( path == null )
  +        {
  +            throw new NullPointerException("path");
  +        }
  +        String uri = normalize( path );
  +
           if( uri.indexOf("/") > -1 )
           {
               String name = uri.substring( 0, uri.indexOf("/") );
  @@ -259,9 +314,135 @@
       * Returns a list of published resources.
       * @return the resources
       */
  -    public synchronized Resource[] getResources()
  +    public URL[] list()
  +    {
  +        ArrayList list = new ArrayList();
  +        Registry[] publishers = 
  +          (Registry[]) m_table.values().toArray( new Registry[0] );
  +        for( int j=0; j<publishers.length; j++ )
  +        {
  +            URL url = publishers[j].getBase();
  +            list.add( url );
  +        }
  +
  +        Resource[] resources = (Resource[]) m_resources.values().toArray( new Resource[0] );
  +        for( int i=0; i<resources.length; i++ )
  +        {
  +            list.add( resources[i].getURL() );
  +        }
  +        return (URL[]) list.toArray( new URL[0] );
  +    }
  +
  +
  +   /**
  +    * Returns a list of published resources.
  +    * @return the resources
  +    */
  +    public Resource[] getResources()
       {
           return (Resource[]) m_resources.values().toArray( new Resource[0] );
  +    }
  +
  +   /**
  +    * Returns a sub-registry by path.
  +    * @param uri the registry path
  +    * @return the subsidiary registry
  +    * @exception InvalidPathException if the supplied path is invalid
  +    * @exception UnknownServiceException if the supplied path does not refer to a registry
  +    */
  +    public ServicePublisher getRegistry( String path ) 
  +      throws UnknownServiceException, InvalidPathException
  +    {
  +        if( path == null )
  +        {
  +            throw new NullPointerException("path");
  +        }
  +
  +        String uri = normalize( path );
  +        if( uri.equals("") )
  +        {
  +            return this;
  +        }
  +
  +        if( uri.indexOf("/") > -1 )
  +        {
  +            String name = uri.substring( 0, uri.indexOf("/") );
  +            Registry child = (Registry) m_table.get( name );
  +            if( child != null )
  +            {
  +                return child.getRegistry( uri.substring( uri.indexOf("/") + 1, uri.length() ) );
  +            }
  +            else
  +            {
  +                final String error = "Invalid path element: " + name;
  +                throw new InvalidPathException( uri, error );
  +            }
  +        }
  +        else
  +        {
  +            //
  +            // its an immediate registry
  +            //
  +
  +            ServicePublisher child = (ServicePublisher) m_table.get( uri );
  +            if( child != null )
  +            {
  +                return child;
  +            }
  +            final String error = "Could not locate the requested registry.";
  +            throw new UnknownServiceException( uri, error );
  +        }
  +    }
  +
  +   /**
  +    * Returns a list of sub-registries.
  +    * @return the subsidiary registries
  +    */
  +    public ServicePublisher[] getRegistries()
  +    {
  +        return (ServicePublisher[]) m_table.values().toArray( new ServicePublisher[0] );
  +    }
  +
  +   /**
  +    * Normalize a supplied path with the base URL of this registry.
  +    * @param path the uri path to normalize
  +    * @return the normalized path relative to this registry
  +    */
  +    public String normalize( String path )
  +    {
  +        try
  +        {
  +            return normalize( new URL( getBase(), path ) );
  +        }
  +        catch( Throwable e )
  +        {
  +            throw new RuntimeException( path + ", cause: " + e.toString() );
  +        }
  +    }
  +
  +   /**
  +    * Normalize a supplied path with the base URL of this registry.
  +    * @param path the uri path to normalize
  +    * @return the normalized path relative to this registry
  +    */
  +    public String normalize( URL url )
  +    {
  +        String p = url.getPath();
  +        String root = getBase().getPath();
  +        if( p.startsWith( root ) )
  +        {
  +            String result = p.substring( root.length() );
  +            if( url.getQuery() != null )
  +            {
  +                result = result + "?" + url.getQuery();
  +            }
  +            if( url.getRef() != null )
  +            {
  +                result = result + "#" + url.getRef();
  +            }
  +            return result;
  +        }
  +        return p;
       }
   }
   
  
  
  
  1.4       +9 -30     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/Handler.java
  
  Index: Handler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/Handler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Handler.java	9 Sep 2002 13:34:50 -0000	1.3
  +++ Handler.java	27 Sep 2002 11:13:33 -0000	1.4
  @@ -36,11 +36,6 @@
        private Registry m_registry;
   
       /**
  -     * The connection object.
  -     */
  -     private URLConnection m_connection;
  -
  -    /**
        * Creation of a new handler.
        * @param host the host domain name
        * @param registry the service resource management context
  @@ -61,18 +56,13 @@
       protected URLConnection openConnection( final URL url )
         throws IOException
       {
  -        if( m_connection == null ) 
  -        {
  -            m_connection = new ServiceURLConnection( url, m_registry );
  -            m_connection.connect();
  -        }
  -        return m_connection;
  +        return new ServiceURLConnection( url, m_registry );
       }
   
       /**
        * Parses the string representation of a <code>URL</code> into a
        * <code>URL</code> object.
  -     * e.g. service:///root/myService
  +     * e.g. native:/root/myService
        * <p>
        * If there is any inherited context, then it has already been
        * copied into the <code>URL</code> argument.
  @@ -125,8 +115,13 @@
           //
   
           String path = url.getPath();
  +        if( remainder.startsWith("//") )
  +        {
  +            remainder = remainder.substring( 2, remainder.length() );
  +        }
  +        
           int pathLoc = remainder.indexOf("/");
  -        if( pathLoc > -1 ) 
  +        if( pathLoc > -1 )
           {
               path = remainder.substring( pathLoc, remainder.length() );
               remainder = remainder.substring( 0, pathLoc );
  @@ -144,7 +139,6 @@
           int port = url.getPort();
           if( port == -1 ) port = getDefaultPort();
   
  -
           //
           // create authority string dependending of non-default port reference
           //
  @@ -159,7 +153,7 @@
               authority = host + ":" + port;
           }
   
  -        setURL( url, "service", host, port, authority, user, path, query, ref );
  +        setURL( url, "native", host, port, authority, user, path, query, ref );
       }
   
      /**
  @@ -184,21 +178,6 @@
           {
               result.append( "@" );
               result.append( url.getUserInfo() );
  -        }
  -        if( url.getHost() == null )
  -        {
  -            result.append("localhost");
  -        }
  -        else
  -        {
  -            result.append( url.getHost() );
  -        }
  -        if( url.getPort() != getDefaultPort() )
  -        {
  -            if( url.getPort() != -1 )
  -            {
  -                result.append( ":" + url.getPort() );
  -            }
           }
           if (url.getFile() != null) 
           {
  
  
  
  1.2       +19 -1     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/ServiceLocator.java
  
  Index: ServiceLocator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/ServiceLocator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServiceLocator.java	16 Sep 2002 21:53:12 -0000	1.1
  +++ ServiceLocator.java	27 Sep 2002 11:13:33 -0000	1.2
  @@ -27,6 +27,15 @@
       public URL getBase();
   
      /**
  +    * Resolves an object relative to the supplied URL.
  +    *
  +    * @param url the URL
  +    * @exception Exception is an error occurs
  +    */
  +    Object resolve( URL url ) throws Exception;
  +
  +
  +   /**
       * Select a set of service based on a supplied filter.  A filter is 
       * supplied in the form of a String.  Interpritation of string follows 
       * normal URI semantics (path, query, and reference elements are protocol 
  @@ -34,8 +43,17 @@
       *
       * @param uri the service uri
       * @exception Exception is an install error occurs
  +    * @deprecated
       */
       Resource locate( String uri ) throws UnknownServiceException, InvalidPathException;
  +
  +   /**
  +    * Normalize a supplied path with the base URL of this registry.
  +    * @param path the uri path to normalize
  +    * @return the normalized path relative to this registry
  +    * @deprecated
  +    */
  +    //public String normalize( String path );
   
   }
   
  
  
  
  1.2       +24 -1     jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/ServicePublisher.java
  
  Index: ServicePublisher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/ServicePublisher.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServicePublisher.java	16 Sep 2002 21:53:12 -0000	1.1
  +++ ServicePublisher.java	27 Sep 2002 11:13:33 -0000	1.2
  @@ -7,6 +7,8 @@
    */
   package org.apache.excalibur.merlin.service;
   
  +import java.net.URL;
  +
   import org.apache.excalibur.merlin.model.Resource;
   
   /**
  @@ -22,5 +24,26 @@
       * @return the resources
       */
       Resource[] getResources();
  +
  +   /**
  +    * Returns a list of sub-registries.
  +    * @return the subsidiary registries
  +    */
  +    public URL[] list();
  +
  +
  +   /**
  +    * Returns a list of sub-registries.
  +    * @return the subsidiary registries
  +    */
  +    public ServicePublisher[] getRegistries();
  +
  +   /**
  +    * Returns a sub-registry by path.
  +    * @param uri the registry path
  +    * @return the subsidiary registry
  +    */
  +    public ServicePublisher getRegistry( String uri ) throws UnknownServiceException, InvalidPathException;
  +
   }
   
  
  
  
  1.4       +12 -35    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/ServiceURLConnection.java
  
  Index: ServiceURLConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/ServiceURLConnection.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServiceURLConnection.java	15 Sep 2002 00:19:37 -0000	1.3
  +++ ServiceURLConnection.java	27 Sep 2002 11:13:33 -0000	1.4
  @@ -63,47 +63,20 @@
               throw new IOException("URL has not been initialized.");
           }
   
  -        //
  -        // make sure that we are only dealing with the strict URL
  -        // (i.e. no query or ref elements in the URL)
  -        //
  -
  -        String path = url.toExternalForm();
  -        int queryIndex = path.indexOf("?");
  -        if( queryIndex > -1 )
  +        try
           {
  -            path = path.substring( 0, queryIndex );
  +            m_object = m_registry.resolve( m_url );
           }
  -        int refIndex = path.indexOf("#");
  -        if( refIndex > -1 )
  +        catch( Throwable e )
           {
  -            path = path.substring( 0, refIndex );
  +            final String error = e.toString();
  +            throw new IOException( error );
           }
  -
  -        //
  -        // establish the primary object reference using the strict URL
  -        //
  -
  -        m_object = getObject( path );
  -     }
  +    }
   
       /**
  -     * Return the Object associated with the supplied path or null if 
  -     * no object exists relative to the path.
  -     * @param path the path
  -     * @return the Object reference
  -     */
  -     private Object getObject( String path ) throws IOException
  -     {
  -         return this;
  -     }
  -
  -    /**
  -     * Returns the object referenced by the URL.  If a connection has not been 
  -     * performed, a commection and retrival of the object reference will be 
  -     * performed.  A client application should narrow the object to the 
  -     * appropriate CORBA type.
  -     * @return and instance of org.omg.CORBA.Object
  +     * Returns the object referenced by the URL.
  +     * @return and service instance 
        * @exception IOException if an error occurs whhile attempting to retireve 
        *   the object reference.
        */
  @@ -127,6 +100,10 @@
        */
       public Object getContent( Class[] classes ) throws IOException 
       {
  +        if( m_object == null )
  +        {
  +            connect();
  +        }
           return m_object;
       }
   }
  
  
  
  1.3       +3 -3      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/ServiceURLFactory.java
  
  Index: ServiceURLFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/ServiceURLFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServiceURLFactory.java	9 Sep 2002 13:34:50 -0000	1.2
  +++ ServiceURLFactory.java	27 Sep 2002 11:13:33 -0000	1.3
  @@ -17,7 +17,7 @@
   import java.net.URLStreamHandler;
   
   /**
  - * URL protocol handler factory for th eservice protocol.
  + * URL protocol handler factory for the native access protocol.
    * @see Handler
    * @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
    */
  @@ -48,11 +48,11 @@
       /**
        * Returns a stream URL handler for the service protocol.
        * @param protocol the protocol
  -     * @return a service protocol handler if the supplied protocol is "service" else null
  +     * @return a service protocol handler if the supplied protocol is "native" else null
        */
        public URLStreamHandler createURLStreamHandler( String protocol )
        {
  -         if( protocol.equals("service") )
  +         if( protocol.equals("native") )
            {
                return new Handler( m_host, m_registry );
            }
  
  
  
  1.6       +2 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/UnknownServiceException.java
  
  Index: UnknownServiceException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/service/UnknownServiceException.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- UnknownServiceException.java	8 Sep 2002 17:24:55 -0000	1.5
  +++ UnknownServiceException.java	27 Sep 2002 11:13:33 -0000	1.6
  @@ -47,7 +47,7 @@
       */
       public String getMessage()
       {
  -        return super.getMessage() + " from the url " + getPath();
  +        return super.getMessage() + " from the url: '" + getPath() + "'";
       }
   
   }
  
  
  
  1.5       +1 -1      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/BasicComponent.java
  
  Index: BasicComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/BasicComponent.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BasicComponent.java	22 Aug 2002 13:43:02 -0000	1.4
  +++ BasicComponent.java	27 Sep 2002 11:13:34 -0000	1.5
  @@ -20,7 +20,7 @@
    * @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
    */
   public class BasicComponent extends AbstractLogEnabled 
  -implements Contextualizable, Configurable, Initializable, Startable, BasicService, Disposable
  +implements Contextualizable, Configurable, Initializable, Startable, BasicService, NullService, Disposable
   {
   
       private String m_location;
  
  
  
  1.4       +3 -0      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/BasicComponent.xinfo
  
  Index: BasicComponent.xinfo
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/BasicComponent.xinfo,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BasicComponent.xinfo	13 Sep 2002 14:57:33 -0000	1.3
  +++ BasicComponent.xinfo	27 Sep 2002 11:13:34 -0000	1.4
  @@ -18,6 +18,9 @@
       <service> 
         <reference type="org.apache.excalibur.playground.BasicService"/>
       </service> 
  +    <service> 
  +      <reference type="org.apache.excalibur.playground.NullService"/>
  +    </service> 
     </services>
   
   </type>
  
  
  
  1.4       +6 -2      jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/SimpleComponent.xinfo
  
  Index: SimpleComponent.xinfo
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/playground/SimpleComponent.xinfo,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SimpleComponent.xinfo	13 Sep 2002 14:57:33 -0000	1.3
  +++ SimpleComponent.xinfo	27 Sep 2002 11:13:34 -0000	1.4
  @@ -10,9 +10,13 @@
     </info>
   
     <services>
  -    <service> 
  +    <service>
  +      <attributes>
  +        <attribute key="avalon:service.servlet" 
  +          value="simple.jsp"/>
  +      </attributes> 
         <reference type="org.apache.excalibur.playground.SimpleService"/>
  -    </service> 
  +    </service>
     </services>
   
     <dependencies>
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>