avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/verifier AssemblyVerifier.java
Date Sun, 09 Jun 2002 00:29:49 GMT
donaldp     2002/06/08 17:29:49

  Modified:    containerkit/src/java/org/apache/excalibur/containerkit/metainfo
                        ServiceReference.java ServiceDescriptor.java
               containerkit/src/java/org/apache/excalibur/containerkit/verifier
                        AssemblyVerifier.java
  Removed:     containerkit/src/java/org/apache/excalibur/containerkit/metainfo
                        AbstractServiceDescriptor.java
  Log:
  Break inheritance tree wrt ServiceReference/ServiceDescriptor and have ServiceDescriptor
nest a ServiceReference.
  
  Revision  Changes    Path
  1.2       +61 -6     jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metainfo/ServiceReference.java
  
  Index: ServiceReference.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metainfo/ServiceReference.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServiceReference.java	7 Jun 2002 10:57:27 -0000	1.1
  +++ ServiceReference.java	9 Jun 2002 00:29:49 -0000	1.2
  @@ -8,7 +8,6 @@
   package org.apache.excalibur.containerkit.metainfo;
   
   import org.apache.avalon.framework.Version;
  -import java.util.Properties;
   
   /**
    * This service reference defines the type of service required
  @@ -19,19 +18,75 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
  - * @version $Revision: 1.1 $ $Date: 2002/06/07 10:57:27 $
  + * @version $Revision: 1.2 $ $Date: 2002/06/09 00:29:49 $
    */
  -public final class ServiceReference extends AbstractServiceDescriptor
  +public final class ServiceReference
   {
       /**
  -     * Construct a service reference with specified name and version.
  +     * The name of service class.
  +     */
  +    private final String m_name;
  +
  +    /**
  +     * The version of service class.
  +     */
  +    private final Version m_version;
  +
  +    /**
  +     * Construct a service with specified name, version and attributes.
        *
        * @param name the name of the service
        * @param version the version of service
        */
  -    public ServiceReference( final String name, final Version version )
  +    public ServiceReference( final String name,
  +                             final Version version )
       {
  -        super( name, version );
  +        m_name = name;
  +        m_version = version;
       }
   
  +    /**
  +     * Return name of Service (which coresponds to the interface
  +     * name eg org.apache.block.WebServer)
  +     *
  +     * @return the name of the Service
  +     */
  +    public String getName()
  +    {
  +        return m_name;
  +    }
  +
  +    /**
  +     * Return the version of interface
  +     *
  +     * @return the version of interface
  +     */
  +    public Version getVersion()
  +    {
  +        return m_version;
  +    }
  +
  +    /**
  +     * Determine if specified service will match this service.
  +     * To match a service has to have same name and must comply with version.
  +     *
  +     * @param other the other ServiceInfo
  +     * @return true if matches, false otherwise
  +     */
  +    public boolean matches( final ServiceReference other )
  +    {
  +        return
  +            other.getName().equals( m_name ) &&
  +            other.getVersion().complies( m_version );
  +    }
  +
  +    /**
  +     * Convert to a string of format name/version
  +     *
  +     * @return string describing service
  +     */
  +    public String toString()
  +    {
  +        return m_name + "/" + m_version;
  +    }
   }
  
  
  
  1.10      +17 -100   jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metainfo/ServiceDescriptor.java
  
  Index: ServiceDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metainfo/ServiceDescriptor.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ServiceDescriptor.java	8 Jun 2002 21:33:51 -0000	1.9
  +++ ServiceDescriptor.java	9 Jun 2002 00:29:49 -0000	1.10
  @@ -7,9 +7,7 @@
    */
   package org.apache.excalibur.containerkit.metainfo;
   
  -import org.apache.avalon.framework.Version;
   import java.util.Properties;
  -import java.util.Enumeration;
   
   /**
    * This descriptor defines the type of service offerend or required
  @@ -30,127 +28,46 @@
    * upon to work in all containers.</p>
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.9 $ $Date: 2002/06/08 21:33:51 $
  + * @version $Revision: 1.10 $ $Date: 2002/06/09 00:29:49 $
    */
  -public final class ServiceDescriptor extends AbstractServiceDescriptor
  +public final class ServiceDescriptor
  +    extends FeatureDescriptor
   {
  -    private static final String[] EMPTY_SET = new String[0];
  -
  -    /**
  -     * The arbitrary set of attributes associated with service.
  -     */
  -    private final Properties m_attributes;
  -
       /**
  -     * A reference to the ComponentInfo instance that this descriptor
  -     * is contained by.
  +     * The service reference that descriptor is describing.
        */
  -     private ComponentInfo m_parent;
  +    private final ServiceReference m_serviceReference;
   
       /**
  -     * Construct a service with specified name and version.
  +     * Construct a service descriptor for specified ServiceReference.
        *
  -     * @param name the name of the service
  -     * @param version the version of service
  +     * @param serviceReference the ServiceReference
        */
  -    public ServiceDescriptor( final String name, final Version version )
  +    public ServiceDescriptor( final ServiceReference serviceReference )
       {
  -        this( name, version, null );
  +        this( serviceReference, null );
       }
   
       /**
        * Construct a service with specified name, version and attributes.
        *
  -     * @param name the name of the service
  -     * @param version the version of service
  +     * @param serviceReference the ServiceReference
        * @param attributes the attributes of service
        */
  -    public ServiceDescriptor( final String name,
  -                              final Version version,
  +    public ServiceDescriptor( final ServiceReference serviceReference,
                                 final Properties attributes )
       {
  -        this( name, version, null, null );
  -    }
  -
  -    /**
  -     * Construct a service with specified name, version, attributes and parent.
  -     *
  -     * @param name the name of the service
  -     * @param version the version of service
  -     * @param attributes the attributes of service
  -     * @param parent the component info publishing this service
  -     */
  -    public ServiceDescriptor( final String name,
  -                              final Version version,
  -                              final Properties attributes,
  -                              final ComponentInfo parent )
  -    {
  -        super( name, version );
  -        m_attributes = attributes;
  -        m_parent = parent;
  +        super( attributes );
  +        m_serviceReference = serviceReference;
       }
   
       /**
  -     * Return the attribute for specified key.
  +     * Retrieve the service that service descriptor refers to.
        *
  -     * @return the attribute for specified key.
  +     * @return
        */
  -    public String getAttribute( final String key )
  +    public ServiceReference getServiceReference()
       {
  -        if( null == m_attributes )
  -        {
  -            return null;
  -        }
  -        else
  -        {
  -            return m_attributes.getProperty( key );
  -        }
  +        return m_serviceReference;
       }
  -
  -    /**
  -     * Return the attribute for specified key.
  -     *
  -     * @return the attribute for specified key.
  -     */
  -    public String getAttribute( final String key,
  -                                final String defaultValue )
  -    {
  -        if( null == m_attributes )
  -        {
  -            return defaultValue;
  -        }
  -        else
  -        {
  -            return m_attributes.getProperty( key, defaultValue );
  -        }
  -    }
  -
  -   /**
  -    * Returns the set of attribute names available under this descriptor.
  -    * 
  -    * @return an array of the properties names held by the descriptor.
  -    */
  -    public String[] getAttributeNames()
  -    {
  -        if( null == m_attributes )
  -        {
  -            return EMPTY_SET;
  -        }
  -        else
  -        {
  -            return (String[]) m_attributes.keySet().toArray( EMPTY_SET );
  -        }
  -    }
  -
  -    /**
  -     * Return the <code>ComponentInfo</code> instance that is the parent of

  -     * this service descriptor.
  -     *
  -     * @return the parent component info instance or null if undefined.
  -     */
  -    public ComponentInfo getParent()
  -    {
  -        return m_parent;
  -    }
  -
   }
  
  
  
  1.9       +5 -3      jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/verifier/AssemblyVerifier.java
  
  Index: AssemblyVerifier.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/verifier/AssemblyVerifier.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AssemblyVerifier.java	8 Jun 2002 21:33:51 -0000	1.8
  +++ AssemblyVerifier.java	9 Jun 2002 00:29:49 -0000	1.9
  @@ -45,7 +45,7 @@
    * </ul>
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.8 $ $Date: 2002/06/08 21:33:51 $
  + * @version $Revision: 1.9 $ $Date: 2002/06/09 00:29:49 $
    */
   public class AssemblyVerifier
       extends AbstractLogEnabled
  @@ -551,7 +551,8 @@
           final Class[] classes = new Class[ services.length ];
           for( int i = 0; i < services.length; i++ )
           {
  -            final String classname = services[ i ].getName();
  +            final ServiceReference service = services[ i ].getServiceReference();
  +            final String classname = service.getName();
               try
               {
                   classes[ i ] = classLoader.loadClass( classname );
  @@ -584,7 +585,8 @@
       {
           for( int i = 0; i < candidates.length; i++ )
           {
  -            if( service.matches( candidates[ i ] ) )
  +            final ServiceReference other = candidates[ i ].getServiceReference();
  +            if( service.matches( other ) )
               {
                   return true;
               }
  
  
  

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


Mime
View raw message