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/12 10:07:44 UTC

cvs commit: jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/builder ServiceBuilder.java TypeBuilder.java XMLServiceCreator.java XMLTypeCreator.java

mcconnell    2002/09/12 01:07:43

  Modified:    meta/src/java/org/apache/excalibur/meta example-service.xml
                        service.dtd
               meta/src/java/org/apache/excalibur/meta/info Service.java
               meta/src/java/org/apache/excalibur/meta/info/builder
                        ServiceBuilder.java TypeBuilder.java
                        XMLServiceCreator.java XMLTypeCreator.java
  Log:
  Addition of classname and version accessors.
  
  Revision  Changes    Path
  1.2       +1 -0      jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/example-service.xml
  
  Index: example-service.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/example-service.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- example-service.xml	12 Sep 2002 05:35:33 -0000	1.1
  +++ example-service.xml	12 Sep 2002 08:07:43 -0000	1.2
  @@ -7,6 +7,7 @@
   -->
   
   <service>
  +  <version>1.2</version>
     <attributes>
       <attribute key="avalon:service.name" value="example"/>
       <attribute key="avalon:service.href" value="http:\\www.somewhere.com\description.html"/>
  
  
  
  1.2       +8 -2      jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/service.dtd
  
  Index: service.dtd
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/service.dtd,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- service.dtd	12 Sep 2002 05:35:33 -0000	1.1
  +++ service.dtd	12 Sep 2002 08:07:43 -0000	1.2
  @@ -20,12 +20,18 @@
     -->
   
   <!--
  -A service element is the document root, it defines:
  +A service element is the document root, it contains:
   
   attributes     an attributes set
  +
  +It includes the attribute
  +
  +version    #.#.# (default value 1.0)
  +
   -->
   
  -<!ELEMENT service (attributes?)>
  +<!ELEMENT service (version?,attributes?)>
  +  <!ELEMENT version      (#PCDATA) >
   
   <!--
   The attributes element contains a list of attributes for feature.
  
  
  
  1.2       +84 -3     jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/Service.java
  
  Index: Service.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/Service.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Service.java	12 Sep 2002 05:35:33 -0000	1.1
  +++ Service.java	12 Sep 2002 08:07:43 -0000	1.2
  @@ -9,6 +9,8 @@
   
   import java.util.Properties;
   
  +import org.apache.avalon.framework.Version;
  +
   /**
    * This class contains the meta information about a particular
    * service. It contains a set of attributes qualifying the service;
  @@ -18,13 +20,92 @@
    */
   public class Service extends Descriptor
   {
  +    private static final Version DEFAULT_VERSION = Version.getVersion( "1.0" );
  +
      /**
  -    * Creation of a new Service instance using a supplied properties argument.
  +    * The service classname key.
  +    */
  +    private final String m_classname;
  +
  +   /**
  +    * The service version.
  +    */
  +    private final Version m_version;
  +
  +   /**
  +    * Creation of a new Service instance.
       *
  +    * @param classname the classname of the service
  +    */
  +    public Service( final String classname )
  +    {
  +        this( classname, null );
  +    }
  +
  +   /**
  +    * Creation of a new Service instance using a classname and supplied properties argument.
  +    *
  +    * @param classname the classname of the service
  +    * @param version the service version
       * @param attributes the set of attributes to assign to the descriptor
       */
  -    public Service( final Properties attributes )
  +    public Service( final String classname, final Version version )
  +    {
  +        this( classname, version, null );
  +    }
  +
  +   /**
  +    * Creation of a new Service instance using a classname and supplied properties argument.
  +    *
  +    * @param classname the classname of the service
  +    * @param version the service version
  +    * @param attributes the set of attributes to assign to the descriptor
  +    */
  +    public Service( final String classname, final Version version, final Properties attributes )
       {
           super( attributes );
  +        if( classname == null )
  +        {
  +            throw new NullPointerException( "classname" );
  +        }
  +        m_version = version;
  +        m_classname = classname;
  +    }
  +
  +   /**
  +    * Return the service classname key.
  +    * @return the service classname
  +    */
  +    public String getClassname()
  +    {
  +        return m_classname;
  +    }
  +
  +   /**
  +    * Return the service version.
  +    * @return the version
  +    */
  +    public Version getVersion()
  +    {
  +        if( m_version == null )
  +        {
  +            return DEFAULT_VERSION;
  +        }
  +        return m_version;
  +    }
  +
  +    /**
  +     * Determine if supplied reference will match this service.
  +     * To match a service has to have same classname and must comply with version.
  +     *
  +     * @param reference the reference descriptor
  +     * @return true if matches, false otherwise
  +     */
  +    public boolean matches( final ReferenceDescriptor reference )
  +    {
  +        return
  +            reference.getClassname().equals( getClassname() ) &&
  +            reference.getVersion().complies( getVersion() );
       }
  +
   }
  
  
  
  1.2       +4 -1      jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/builder/ServiceBuilder.java
  
  Index: ServiceBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/builder/ServiceBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServiceBuilder.java	12 Sep 2002 06:03:10 -0000	1.1
  +++ ServiceBuilder.java	12 Sep 2002 08:07:43 -0000	1.2
  @@ -128,7 +128,10 @@
   
           if( null == inputStream )
           {
  -            return new Service( null );
  +            final String message =
  +                REZ.getString( "builder.missing-info.error",
  +                               classname );
  +            throw new Exception( message );
           }
   
           //
  
  
  
  1.3       +1 -7      jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/builder/TypeBuilder.java
  
  Index: TypeBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/builder/TypeBuilder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeBuilder.java	21 Aug 2002 03:34:32 -0000	1.2
  +++ TypeBuilder.java	12 Sep 2002 08:07:43 -0000	1.3
  @@ -133,12 +133,6 @@
   
           if( null == inputStream )
           {
  -            //##############################################################//
  -            // Need to upgrade this to handle automated xinfo creation      //
  -            // using implemented interfaces for services, no dependecies,   //
  -            // no context, etc.                                             //
  -            //##############################################################//
  -
               final String message =
                   REZ.getString( "builder.missing-info.error",
                                  classname );
  
  
  
  1.2       +18 -2     jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/builder/XMLServiceCreator.java
  
  Index: XMLServiceCreator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/builder/XMLServiceCreator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLServiceCreator.java	12 Sep 2002 05:35:33 -0000	1.1
  +++ XMLServiceCreator.java	12 Sep 2002 08:07:43 -0000	1.2
  @@ -11,6 +11,7 @@
   import java.util.Properties;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.avalon.framework.Version;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  @@ -87,6 +88,8 @@
   
           final Properties attributes =
               buildAttributes( configuration.getChild( "attributes" ) );
  +        final String versionString = configuration.getChild( "version" ).getValue("1.0");
  +        final Version version = buildVersion( versionString );
   
           if( getLogger().isInfoEnabled() )
           {
  @@ -97,7 +100,7 @@
               getLogger().info( message );
           }
   
  -        return new Service( attributes );
  +        return new Service( classname, version, attributes );
       }
   
       /**
  @@ -125,4 +128,17 @@
           }
           return attributes;
       }
  +
  +    /**
  +     * A utility method to parse a Version object from specified string.
  +     *
  +     * @param version the version string
  +     * @return the created Version object
  +     */
  +    protected Version buildVersion( final String version )
  +    {
  +        return Version.getVersion( version );
  +    }
  +
  +
   }
  
  
  
  1.5       +1 -12     jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/builder/XMLTypeCreator.java
  
  Index: XMLTypeCreator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/builder/XMLTypeCreator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLTypeCreator.java	12 Sep 2002 05:35:33 -0000	1.4
  +++ XMLTypeCreator.java	12 Sep 2002 08:07:43 -0000	1.5
  @@ -422,17 +422,6 @@
           return new ComponentDescriptor( name, classname, version, attributes );
       }
   
  -    /**
  -     * A utility method to parse a Version object from specified string.
  -     *
  -     * @param version the version string
  -     * @return the created Version object
  -     */
  -    protected Version buildVersion( final String version )
  -    {
  -        return Version.getVersion( version );
  -    }
  -
      /**
       * Utility function to create a set of phase descriptor from a configuration.
       * @param config a configuration containing 0..n phase elements
  
  
  

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