donaldp     2002/06/03 21:13:52

  Added:       src/java/org/apache/avalon/phoenix/components/container/metainfo
                        ComponentDescriptor.java ComponentInfo.java
                        DependencyDescriptor.java ServiceDescriptor.java
  Log:
  Add in start of gerneric component info infrastructure
  
  Revision  Changes    Path
  1.1                  
jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/container/metainfo/ComponentDescriptor.java
  
  Index: ComponentDescriptor.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.avalon.phoenix.components.container.metainfo;
  
  import org.apache.avalon.framework.Version;
  
  /**
   * This class is used to provide explicit information to assembler
   * and administrator about the Component. It includes information
   * such as;
   *
   * <ul>
   *   <li>a symbolic name</li>
   *   <li>a display name</li>
   *   <li>classname</li>
   *   <li>version</li>
   * </ul>
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/04 04:13:52 $
   */
  public class ComponentDescriptor
  {
      /**
       * The short name of the Component Type. Useful for displaying
       * human readable strings describing the type in
       * assembly tools or generators.
       */
      private final String m_name;
      private final String m_displayName;
      private final String m_classname;
      private final Version m_version;
  
      public ComponentDescriptor( final String name,
                                  final String displayName,
                                  final String classname,
                                  final Version version )
      {
          m_name = name;
          m_displayName = displayName;
          m_classname = classname;
          m_version = version;
      }
  
      /**
       * Return the symbolic name of component.
       *
       * @return the symbolic name of component.
       */
      public String getName()
      {
          return m_name;
      }
  
      /**
       * Return the display name of component.
       *
       * @return the display name of component.
       */
      public String getDisplayName()
      {
          return m_displayName;
      }
  
      /**
       * Return the classname of component.
       *
       * @return the classname of component.
       */
      public String getClassname()
      {
          return m_classname;
      }
  
      /**
       * Return the version of component.
       *
       * @return the version of component.
       */
      public Version getVersion()
      {
          return m_version;
      }
  }
  
  
  
  
  1.1                  
jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/container/metainfo/ComponentInfo.java
  
  Index: ComponentInfo.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.avalon.phoenix.components.container.metainfo;
  
  /**
   * This class contains the meta information about a particular
   * component type. It describes;
   *
   * <ul>
   *   <li>Human presentable meta data such as name, version, description etc
   *   useful when assembling the system.</li>
   *   <li>the services that this component type is capable of providing</li>
   *   <li>the services that this component type requires to operate (and the
   *   names via which services are accessed)</li>
   * </ul>
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/04 04:13:52 $
   */
  public class ComponentInfo
  {
      private final ComponentDescriptor m_descriptor;
      private final ServiceDescriptor[] m_services;
      private final DependencyDescriptor[] m_dependencies;
  
      /**
       * Basic constructor that takes as parameters all parts.
       */
      public ComponentInfo( final ComponentDescriptor descriptor,
                            final ServiceDescriptor[] services,
                            final DependencyDescriptor[] dependencies )
      {
          m_descriptor = descriptor;
          m_services = services;
          m_dependencies = dependencies;
      }
  
      /**
       * Return meta information that is generallly only required by 
administration tools.
       *
       * It should be loaded on demand and not always present in memory.
       *
       * @return the ComponentDescriptor
       */
      public ComponentDescriptor getComponentDescriptor()
      {
          return m_descriptor;
      }
  
      /**
       * Return the set of Services that this Component is capable of providing.
       *
       * @return the set of Services that this Component is capable of 
providing.
       */
      public ServiceDescriptor[] getServices()
      {
          return m_services;
      }
  
      /**
       * Return the set of Dependencies that this Component requires to operate.
       *
       * @return the set of Dependencies that this Component requires to 
operate.
       */
      public DependencyDescriptor[] getDependencies()
      {
          return m_dependencies;
      }
  
      /**
       * Retrieve a dependency with a particular role.
       *
       * @param role the role
       * @return the dependency or null if it does not exist
       */
      public DependencyDescriptor getDependency( final String role )
      {
          for( int i = 0; i < m_dependencies.length; i++ )
          {
              if( m_dependencies[ i ].getRole().equals( role ) )
              {
                  return m_dependencies[ i ];
              }
          }
  
          return null;
      }
  }
  
  
  
  1.1                  
jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/container/metainfo/DependencyDescriptor.java
  
  Index: DependencyDescriptor.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.avalon.phoenix.components.container.metainfo;
  
  /**
   * A descriptor that describes dependency information for
   * a particular Component. This class contains information
   * about;
   * <ul>
   *   <li>role: the name component uses to look up dependency</li>
   *   <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>
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/04 04:13:52 $
   */
  public final class DependencyDescriptor
  {
      /**
       * The name the component uses to lookup dependency.
       */
      private final String m_role;
  
      /**
       * The service class/interface that the dependency must provide.
       */
      private final ServiceDescriptor m_service;
  
      /**
       * Constructor that has all parts as parameters.
       */
      public DependencyDescriptor( final String role, final ServiceDescriptor 
service )
      {
          m_role = role;
          m_service = service;
      }
  
      /**
       * Return the name the component uses to lookup dependency.
       *
       * @return the name the component uses to lookup dependency.
       */
      public String getRole()
      {
          return m_role;
      }
  
      /**
       * Return the service class/interface that the dependency must provide.
       *
       * @return the service class/interface that the dependency must provide.
       */
      public ServiceDescriptor getService()
      {
          return m_service;
      }
  }
  
  
  
  1.1                  
jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/container/metainfo/ServiceDescriptor.java
  
  Index: ServiceDescriptor.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.avalon.phoenix.components.container.metainfo;
  
  import org.apache.avalon.framework.Version;
  
  /**
   * This descriptor defines the type of service offerend or required
   * by a component. The type corresponds to the class name of the
   * class/interface implemented by component. Associated with each
   * classname is a version object so that different versions of same
   * interface can be represented.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/04 04:13:52 $
   */
  public final class ServiceDescriptor
  {
      /**
       * 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 and version.
       *
       * @param name the name of the service
       * @param version the version of service
       */
      public ServiceDescriptor( final String name, final Version 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 ServiceDescriptor 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;
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to