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/assembly/src/java/org/apache/avalon/assembly/appliance DefaultAppliance.java
Date Thu, 24 Apr 2003 12:16:04 GMT
mcconnell    2003/04/24 05:16:04

  Modified:    merlin/assembly/src/java/org/apache/avalon/assembly/appliance
                        DefaultAppliance.java
  Log:
  Added access to available services to appliance so that an appliance can add or retract
from the computation set of services.
  
  Revision  Changes    Path
  1.14      +61 -30    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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DefaultAppliance.java	20 Apr 2003 12:01:54 -0000	1.13
  +++ DefaultAppliance.java	24 Apr 2003 12:16:03 -0000	1.14
  @@ -276,16 +276,17 @@
   
       public void initialize() throws Exception
       {
  -        if( m_engine == null )
  +        if( m_applianceContext == null )
           {
  -            throw new IllegalStateException( "engine" );
  +            throw new IllegalStateException( "contextualization" );
           }
   
           String classname = getType().getInfo().getClassname();
           try
           {
               m_class = m_engine.loadClass( classname );
  -        } catch( Throwable e )
  +        } 
  +        catch( Throwable e )
           {
               final String error =
                       "Cannot load class for appliance " + this
  @@ -303,7 +304,8 @@
           try
           {
               m_handler = m_lifestyle.createHandler( this, m_engine, m_system );
  -        } catch( Throwable e )
  +        } 
  +        catch( Throwable e )
           {
               final String error =
                       "Unexpected lifestyle handler establishment failure in appliance: "
+ this;
  @@ -326,25 +328,25 @@
        * the implementation will attempt a self assembly prior to
        * resolving the service.
        *
  -     * @param partition the context within the the resolution is applied
  +     * @param source the context within the the resolution is applied
        * @return the resolved object
        * @throws LocatorException if an error occurs
        */
  -    public Object resolve( Object partition )
  +    public Object resolve( Object source )
               throws LocatorException
       {
  -        return resolve( partition, null );
  +        return resolve( source, null );
       }
   
       /**
        * Resolve a object to a value qualified by a supplied service reference.
        *
  -     * @param partition the context within the the resolution is applied
  +     * @param source 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 )
  +    public Object resolve( Object source, String ref )
               throws LocatorException
       {
           if( !m_assembled )
  @@ -355,11 +357,12 @@
               try
               {
                   assemble();
  -            } catch( ApplianceException ae )
  +            } 
  +            catch( ApplianceException ae )
               {
                   final String error =
  -                        "Unable to resolve service due to a self assembly failure in appliance:
"
  -                        + this;
  +                  "Unable to resolve service due to a self assembly failure in appliance:
"
  +                  + this;
                   throw new LocatorException( error, ref, ae );
               }
           }
  @@ -369,16 +372,17 @@
               if( !validReference( ref ) )
               {
                   final String error =
  -                        "Requested service ref: " + ref
  -                        + " is unknown within appliance: " + this;
  +                  "Requested service reference: " + ref
  +                  + " is unknown within appliance: " + this;
                   throw new LocatorException( ref, error );
               }
           }
   
           try
           {
  -            return m_handler.resolve( partition, ref );
  -        } catch( Throwable e )
  +            return m_handler.resolve( source, ref );
  +        } 
  +        catch( Throwable e )
           {
               final String error =
                       "Internal lifestyle handler error in appliance: "
  @@ -387,17 +391,17 @@
           }
       }
   
  -    /**s
  +    /**
        * Release an object
        *
        * @param the object to be reclaimed
        * @param partition the context with respect the reclaimed object is qualified
        */
  -    public void release( Object object, Object partition )
  +    public void release( Object object, Object source )
       {
           try
           {
  -            m_handler.release( object, partition );
  +            m_handler.release( object, source );
           } catch( Throwable e )
           {
               final String error =
  @@ -430,11 +434,31 @@
       /**
        * Return the set of runtime dependencies for the type.
        *
  -     * @return the set of runtim dependencies.
  +     * @return the set of runtime dependencies.
        */
       public DependencyDescriptor[] getDependencies()
       {
  -        return getType().getDependencies();
  +        return m_applianceContext.getProfile().getDependencies();
  +    }
  +
  +    /**
  +     * Return the set of services provides by the appliance.
  +     *
  +     * @return the set of services.
  +     */
  +    public ServiceDescriptor[] getServices()
  +    {
  +        return m_applianceContext.getProfile().getServices();
  +    }
  +
  +    /**
  +     * Return a service descriptor relative to a supplied reference.
  +     *
  +     * @return the service descriptor.
  +     */
  +    public ServiceDescriptor getService( ReferenceDescriptor reference )
  +    {
  +        return m_applianceContext.getProfile().getService( reference );
       }
   
       /**
  @@ -697,9 +721,15 @@
           if( getContextProvider() != null )
           {
               return true;
  -        } else
  +        }
  +        else if( Contextualizable.class.isAssignableFrom( m_class ) )
           {
  -            return org.apache.avalon.framework.context.Contextualizable.class.isAssignableFrom(
m_class );
  +            return true;
  +        }
  +        else
  +        {
  +            return org.apache.avalon.framework.context.Contextualizable.class.
  +              isAssignableFrom( m_class ) ;
           }
       }
   
  @@ -828,7 +858,7 @@
       }
   
       /**
  -     * Add an appliance servicing for a dependency.
  +     * Add an appliance servicing a dependency.
        * @param role the role against which the supplied resource is to be associated
        * @param appliance the appliance that will fulfill the dependency
        */
  @@ -913,8 +943,9 @@
               try
               {
                   supplier =
  -                        m_engine.resolve( graph, stage, getURL().getPath() );
  -            } catch( Throwable e )
  +                  m_engine.resolve( graph, stage, getURL().getPath() );
  +            } 
  +            catch( Throwable e )
               {
                   setEnabled( false );
                   final String error =
  @@ -1043,11 +1074,11 @@
        *   published by the type associated with the profile that this appliance
        *   is handling.
        */
  -    private boolean validReference( String ref )
  +    protected boolean validReference( String ref )
       {
           ServiceDescriptor service =
  -                getType().getService( new ReferenceDescriptor( ref ) );
  +          m_applianceContext.getProfile().getService( new ReferenceDescriptor( ref )  );
  +        //        getType().getService( new ReferenceDescriptor( ref ) );
           return service != null;
       }
  -
   }
  
  
  

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


Mime
View raw message