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/metainfo ComponentDescriptor.java DependencyDescriptor.java ServiceDescriptor.java
Date Thu, 06 Jun 2002 03:04:50 GMT
donaldp     2002/06/05 20:04:50

  Modified:    containerkit/src/java/org/apache/excalibur/containerkit/metainfo
                        ComponentDescriptor.java DependencyDescriptor.java
                        ServiceDescriptor.java
  Log:
  Allow all the descriptors to have arbitrary attributes associated with them. This allows
containers to do container specific magic with out resorting to subclassing.
  
  Revision  Changes    Path
  1.5       +17 -3     jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metainfo/ComponentDescriptor.java
  
  Index: ComponentDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metainfo/ComponentDescriptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ComponentDescriptor.java	6 Jun 2002 02:46:06 -0000	1.4
  +++ ComponentDescriptor.java	6 Jun 2002 03:04:50 -0000	1.5
  @@ -49,7 +49,7 @@
    * </pre>
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.4 $ $Date: 2002/06/06 02:46:06 $
  + * @version $Revision: 1.5 $ $Date: 2002/06/06 03:04:50 $
    */
   public class ComponentDescriptor
   {
  @@ -140,7 +140,14 @@
        */
       public String getAttribute( final String key )
       {
  -        return m_attributes.getProperty( key );
  +        if( null == m_attributes )
  +        {
  +            return null;
  +        }
  +        else
  +        {
  +            return m_attributes.getProperty( key );
  +        }
       }
   
       /**
  @@ -151,6 +158,13 @@
       public String getAttribute( final String key,
                                   final String defaultValue )
       {
  -        return m_attributes.getProperty( key, defaultValue );
  +        if( null == m_attributes )
  +        {
  +            return defaultValue;
  +        }
  +        else
  +        {
  +            return m_attributes.getProperty( key, defaultValue );
  +        }
       }
   }
  
  
  
  1.3       +68 -5     jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metainfo/DependencyDescriptor.java
  
  Index: DependencyDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/metainfo/DependencyDescriptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DependencyDescriptor.java	4 Jun 2002 07:46:29 -0000	1.2
  +++ DependencyDescriptor.java	6 Jun 2002 03:04:50 -0000	1.3
  @@ -7,6 +7,8 @@
    */
   package org.apache.excalibur.containerkit.metainfo;
   
  +import java.util.Properties;
  +
   /**
    * A descriptor that describes dependency information for
    * a particular Component. This class contains information
  @@ -16,12 +18,21 @@
    *   <li>service: the class/interface that the dependency must provide</li>
    * </ul>
    *
  - * <p>Note that in the future we may also add information relating to
  - * constraints on dependency. ie The dependency must be configured in
  - * particular fashion or must be able to provide certain facilities etc</p>
  + * <p>Also associated with each dependency is a set of arbitrary
  + * attributes that can be used to store extra information
  + * about dependency. See {@link ComponentDescriptor} for example
  + * of how to declare the container specific attributes.</p>
  + *
  + * <p>Possible uses for the attributes are to declare container
  + * specific constraints of component. For example a dependency on
  + * a Corba ORB may also require that the Corba ORB contain the
  + * TimeServer and PersistenceStateService at initialization. Or it
  + * may require that the componenet be multi-thread safe or that
  + * it is persistent etc. These are all container specific
  + * demands.</p>
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.2 $ $Date: 2002/06/04 07:46:29 $
  + * @version $Revision: 1.3 $ $Date: 2002/06/06 03:04:50 $
    */
   public final class DependencyDescriptor
   {
  @@ -36,12 +47,29 @@
       private final ServiceDescriptor m_service;
   
       /**
  +     * The arbitrary set of attributes associated with Dependency.
  +     */
  +    private final Properties m_attributes;
  +
  +    /**
  +     * Constructor a dependency sans Attributes.
  +     */
  +    public DependencyDescriptor( final String role,
  +                                 final ServiceDescriptor service )
  +    {
  +        this( role, service, null );
  +    }
  +
  +    /**
        * Constructor that has all parts as parameters.
        */
  -    public DependencyDescriptor( final String role, final ServiceDescriptor service )
  +    public DependencyDescriptor( final String role,
  +                                 final ServiceDescriptor service,
  +                                 final Properties attributes )
       {
           m_role = role;
           m_service = service;
  +        m_attributes = attributes;
       }
   
       /**
  @@ -62,5 +90,40 @@
       public ServiceDescriptor getService()
       {
           return m_service;
  +    }
  +
  +    /**
  +     * Return the attribute for specified key.
  +     *
  +     * @return the attribute for specified key.
  +     */
  +    public String getAttribute( final String key )
  +    {
  +        if( null == m_attributes )
  +        {
  +            return null;
  +        }
  +        else
  +        {
  +            return m_attributes.getProperty( key );
  +        }
  +    }
  +
  +    /**
  +     * 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 );
  +        }
       }
   }
  
  
  
  1.3       +70 -2     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServiceDescriptor.java	4 Jun 2002 07:46:29 -0000	1.2
  +++ ServiceDescriptor.java	6 Jun 2002 03:04:50 -0000	1.3
  @@ -8,6 +8,7 @@
   package org.apache.excalibur.containerkit.metainfo;
   
   import org.apache.avalon.framework.Version;
  +import java.util.Properties;
   
   /**
    * This descriptor defines the type of service offerend or required
  @@ -16,8 +17,19 @@
    * classname is a version object so that different versions of same
    * interface can be represented.
    *
  + * <p>Also associated with each service is a set of arbitrary
  + * attributes that can be used to store extra information
  + * about service. See {@link ComponentDescriptor} for example
  + * of how to declare the container specific attributes.</p>
  + *
  + * <p>Possible uses for the attributes are to declare a service
  + * as "stateless", "pass-by-value", "remotable" or even to attach
  + * attributes such as security or transaction constraints. These
  + * attributes are container specific and should not be relied
  + * upon to work in all containers.</p>
  + *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.2 $ $Date: 2002/06/04 07:46:29 $
  + * @version $Revision: 1.3 $ $Date: 2002/06/06 03:04:50 $
    */
   public final class ServiceDescriptor
   {
  @@ -32,6 +44,11 @@
       private final Version m_version;
   
       /**
  +     * The arbitrary set of attributes associated with service.
  +     */
  +    private final Properties m_attributes;
  +
  +    /**
        * Construct a service with specified name and version.
        *
        * @param name the name of the service
  @@ -39,8 +56,23 @@
        */
       public ServiceDescriptor( final String name, final Version version )
       {
  +        this( name, version, null );
  +    }
  +
  +    /**
  +     * Construct a service with specified name, version and attributes.
  +     *
  +     * @param name the name of the service
  +     * @param version the version of service
  +     * @param attributes the attributes of service
  +     */
  +    public ServiceDescriptor( final String name,
  +                              final Version version,
  +                              final Properties attributes )
  +    {
           m_name = name;
           m_version = version;
  +        m_attributes = attributes;
       }
   
       /**
  @@ -75,7 +107,8 @@
       {
           return
               other.getName().equals( m_name ) &&
  -            other.getVersion().complies( m_version );
  +            other.getVersion().complies( m_version ) &&
  +            other.m_attributes.equals( m_attributes );
       }
   
       /**
  @@ -86,5 +119,40 @@
       public String toString()
       {
           return m_name + "/" + m_version;
  +    }
  +
  +    /**
  +     * Return the attribute for specified key.
  +     *
  +     * @return the attribute for specified key.
  +     */
  +    public String getAttribute( final String key )
  +    {
  +        if( null == m_attributes )
  +        {
  +            return null;
  +        }
  +        else
  +        {
  +            return m_attributes.getProperty( key );
  +        }
  +    }
  +
  +    /**
  +     * 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 );
  +        }
       }
   }
  
  
  

--
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