You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by do...@apache.org on 2002/06/04 02:46:21 UTC

cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/lifecycle/metainfo ComponentDescriptor.java ComponentInfo.java DependencyDescriptor.java ServiceDescriptor.java

donaldp     2002/06/03 17:46:21

  Added:       src/java/org/apache/avalon/phoenix/components/lifecycle/metainfo
                        ComponentDescriptor.java ComponentInfo.java
                        DependencyDescriptor.java ServiceDescriptor.java
  Log:
  Temporarily commit some files so I can move between machines.
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/lifecycle/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.lifecycle.metainfo;
  
  import org.apache.avalon.framework.Version;
  
  /**
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   */
  public class ComponentDescriptor
  {
      /**
       * The short name of the Blo
       * ck. Useful for displaying
       * human readable strings describing the type in
       * assembly tools or generators.
       */
      private final String m_name;
      private final String m_classname;
      private final Version m_version;
      //private final ConfigSchema    m_schema;
  
      public ComponentDescriptor( final String name,
                              final String classname,
                              final Version version )
      {
          m_name = name;
          m_classname = classname;
          m_version = version;
      }
  
      /**
       * Retrieve the name of Block type.
       *
       * @return the name of Block type.
       */
      public String getName()
      {
          return m_name;
      }
  
      /**
       * Retrieve the Class Name of Block.
       *
       * @return the Class Name of block
       */
      public String getClassname()
      {
          return m_classname;
      }
  
      /**
       * Retrieve Version of current Block.
       *
       * @return the version of block
       */
      public Version getVersion()
      {
          return m_version;
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/lifecycle/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.lifecycle.metainfo;
  
  /**
   * This class contains meta-information of use to administative
   * tools and the kernel. It describes the services offered by a type
   * of block, the dependencies of the block, the management interface of
   * block (if any) and also contains information useful to presenting
   * information in administative screens (like human readable names etc).
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   */
  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;
      }
  
      /**
       * This returns a list of Services that this block exports.
       *
       * @return an array of Services
       */
      public ServiceDescriptor[] getServices()
      {
          return m_services;
      }
  
      /**
       * Return an array of Service dependencies that this Block depends upon.
       *
       * @return an array of Service dependencies
       */
      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/lifecycle/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.lifecycle.metainfo;
  
  /**
   * A descriptor that describes dependency information for Block.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   */
  public final class DependencyDescriptor
  {
      private final String m_role;
      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 role of dependency.
       *
       * The role is what is used by block implementor to
       * aquire dependency in ComponentManager.
       *
       * @return the name of the dependency
       */
      public String getRole()
      {
          return m_role;
      }
  
      /**
       * Return Service dependency provides.
       *
       * @return the service dependency provides
       */
      public ServiceDescriptor getService()
      {
          return m_service;
      }
  }
  
  
  
  1.1                  jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/lifecycle/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.lifecycle.metainfo;
  
  import org.apache.avalon.framework.Version;
  
  /**
   * This class describes the meta info of a service offered by a Block.
   * Each service is defined by an interface name and the version of that
   * interface.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   */
  public final class ServiceDescriptor
  {
      private final Version m_version;
      private final String m_name;
  
      /**
       * 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 the version of interface
       *
       * @return the version of interface
       */
      public Version getVersion()
      {
          return m_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;
      }
  
      /**
       * 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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>