hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-hivemind/library/src/descriptor/META-INF hivemodule.xml
Date Sun, 07 Nov 2004 12:35:01 GMT
hlship      2004/11/07 04:35:01

  Modified:    .        .classpath
               library/src/test/org/apache/hivemind/lib/util
                        TestAdaptorRegistry.java
               library/src/java/org/apache/hivemind/lib/util
                        UtilMessages.java UtilStrings.properties
               src/documentation/content/xdocs site.xml
               library/src/descriptor/META-INF hivemodule.xml
  Added:       library/src/java/org/apache/hivemind/lib/adapter
                        AdapterStrings.properties AdapterMessages.java
                        AdapterRegistryFactory.java
                        AdapterRegistryContribution.java
                        AdapterRegistryParameter.java
               library/src/java/org/apache/hivemind/lib/util
                        AdapterRegistry.java AdapterRegistryImpl.java
               library/src/documentation/content/xdocs/hivemind-lib
                        AdapterRegistryFactory.xml
               library/src/test/org/apache/hivemind/lib/adapter
                        AdapterFactoryIntegration.xml
                        CatchAllToStringAdapter.java ToStringAdapter.java
                        TestAdapterRegistryFactory.java
  Removed:     library/src/java/org/apache/hivemind/lib/adaptor
                        AdaptorRegistryFactory.java
                        AdaptorRegistryParameter.java AdaptorMessages.java
                        AdaptorStrings.properties
                        AdaptorRegistryContribution.java
               library/src/test/org/apache/hivemind/lib/adaptor
                        ToStringAdaptor.java CatchAllToStringAdaptor.java
                        AdaptorFactoryIntegration.xml
                        TestAdaptorRegistryFactory.java
               library/src/java/org/apache/hivemind/lib/util
                        AdaptorRegistryImpl.java AdaptorRegistry.java
               library/src/documentation/content/xdocs/hivemind-lib
                        AdaptorRegistryFactory.xml
  Log:
  Rename "Adaptor" to "Adapter".
  
  Revision  Changes    Path
  1.41      +1 -1      jakarta-hivemind/.classpath
  
  Index: .classpath
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/.classpath,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- .classpath	2 Nov 2004 22:32:16 -0000	1.40
  +++ .classpath	7 Nov 2004 12:35:00 -0000	1.41
  @@ -1,6 +1,6 @@
   <?xml version="1.0" encoding="UTF-8"?>
   <classpath>
  -	<classpathentry exported="true" kind="var" path="CLOVER_RUNTIME"/>
  +	<classpathentry kind="var" path="CLOVER_RUNTIME"/>
   	<classpathentry output="framework/target/eclipse-test-classes" kind="src" path="framework/src/conf"/>
   	<classpathentry output="framework/target/eclipse-classes" kind="src" path="framework/src/java"/>
   	<classpathentry output="framework/target/eclipse-test-classes" kind="src" path="framework/src/test"/>
  
  
  
  1.2       +11 -11    jakarta-hivemind/library/src/test/org/apache/hivemind/lib/util/TestAdaptorRegistry.java
  
  Index: TestAdaptorRegistry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/src/test/org/apache/hivemind/lib/util/TestAdaptorRegistry.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestAdaptorRegistry.java	5 Nov 2004 15:58:34 -0000	1.1
  +++ TestAdaptorRegistry.java	7 Nov 2004 12:35:00 -0000	1.2
  @@ -18,12 +18,12 @@
   import java.util.List;
   import java.util.Map;
   
  -import org.apache.hivemind.lib.util.AdaptorRegistry;
  -import org.apache.hivemind.lib.util.AdaptorRegistryImpl;
  +import org.apache.hivemind.lib.util.AdapterRegistry;
  +import org.apache.hivemind.lib.util.AdapterRegistryImpl;
   import org.apache.hivemind.test.HiveMindTestCase;
   
   /**
  - * Tests the {@link org.apache.hivemind.lib.util.AdaptorRegistryImpl}class.
  + * Tests the {@link org.apache.hivemind.lib.util.AdapterRegistryImpl}class.
    * 
    * @author Howard Lewis Ship
    * @since 1.1
  @@ -32,9 +32,9 @@
   public class TestAdaptorRegistry extends HiveMindTestCase
   {
   
  -    private AdaptorRegistry build()
  +    private AdapterRegistry build()
       {
  -        AdaptorRegistry result = new AdaptorRegistryImpl();
  +        AdapterRegistry result = new AdapterRegistryImpl();
   
           result.register(Object.class, "OBJECT");
           result.register(Object[].class, "OBJECT[]");
  @@ -51,7 +51,7 @@
   
       private void expect(String expected, Class subjectClass)
       {
  -        Object actual = build().getAdaptor(subjectClass);
  +        Object actual = build().getAdapter(subjectClass);
   
           assertEquals(expected, actual);
       }
  @@ -115,25 +115,25 @@
   
       public void testNoMatch()
       {
  -        AdaptorRegistry r = new AdaptorRegistryImpl();
  +        AdapterRegistry r = new AdapterRegistryImpl();
   
           r.register(String.class, "STRING");
   
           try
           {
  -            r.getAdaptor(Boolean.class);
  +            r.getAdapter(Boolean.class);
   
               unreachable();
           }
           catch (IllegalArgumentException ex)
           {
  -            assertEquals(UtilMessages.adaptorNotFound(Boolean.class), ex.getMessage());
  +            assertEquals(UtilMessages.adapterNotFound(Boolean.class), ex.getMessage());
           }
       }
   
       public void testToString()
       {
  -        AdaptorRegistry r = new AdaptorRegistryImpl();
  +        AdapterRegistry r = new AdapterRegistryImpl();
   
           r.register(String.class, "STRING");
   
  @@ -142,7 +142,7 @@
   
       public void testDuplicateRegistration()
       {
  -        AdaptorRegistry r = new AdaptorRegistryImpl();
  +        AdapterRegistry r = new AdapterRegistryImpl();
   
           r.register(String.class, "STRING");
   
  
  
  
  1.1                  jakarta-hivemind/library/src/java/org/apache/hivemind/lib/adapter/AdapterStrings.properties
  
  Index: AdapterStrings.properties
  ===================================================================
  #
  # Copyright 2004 The Apache Software Foundation
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  adapter-wrong-interface=Adaptor {0} (for class {1}) does not implement the {2} interface.
  improper-service-method=Method ''{0}'' is not suitable for use with the AdaptorRegistryFactory; the first parameter should be an object type (used to select the adapter).
  to-string=<AdapterRegistry for service {0}({1})>
  
  
  
  
  1.1                  jakarta-hivemind/library/src/java/org/apache/hivemind/lib/adapter/AdapterMessages.java
  
  Index: AdapterMessages.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.lib.adapter;
  
  import org.apache.hivemind.impl.MessageFormatter;
  import org.apache.hivemind.service.ClassFabUtils;
  import org.apache.hivemind.service.MethodSignature;
  
  /**
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class AdapterMessages
  {
      private static final MessageFormatter _formatter = new MessageFormatter(AdapterMessages.class,
              "AdapterStrings");
  
      public static String adapterWrongInterface(Object adaptor, Class registerClass,
              Class serviceInterface)
      {
          return _formatter.format("adapter-wrong-interface", adaptor, ClassFabUtils
                  .getJavaClassName(registerClass), serviceInterface.getName());
      }
  
      public static String improperServiceMethod(MethodSignature sig)
      {
          return _formatter.format("improper-service-method", sig);
      }
  
      public static String toString(String serviceId, Class serviceInterface)
      {
          return _formatter.format("to-string", serviceId, serviceInterface.getName());
      }
  }
  
  
  1.1                  jakarta-hivemind/library/src/java/org/apache/hivemind/lib/adapter/AdapterRegistryFactory.java
  
  Index: AdapterRegistryFactory.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.lib.adapter;
  
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Modifier;
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.hivemind.HiveMind;
  import org.apache.hivemind.ServiceImplementationFactory;
  import org.apache.hivemind.ServiceImplementationFactoryParameters;
  import org.apache.hivemind.lib.util.AdapterRegistry;
  import org.apache.hivemind.lib.util.AdapterRegistryImpl;
  import org.apache.hivemind.service.ClassFab;
  import org.apache.hivemind.service.ClassFabUtils;
  import org.apache.hivemind.service.ClassFactory;
  import org.apache.hivemind.service.MethodIterator;
  import org.apache.hivemind.service.MethodSignature;
  
  /**
   * Constructs a service where the first parameter of each method is used to selected an adapter from
   * an {@link org.apache.hivemind.lib.util.AdapterRegistry}. The method invocation is then delegated
   * to the adapter.
   * <p>
   * The service factory parameter defines a configuration (of
   * {@link org.apache.hivemind.lib.adapter.AdapterRegistryContribution}that provide the mapping from
   * Java classes (or interfaces) to adapter instances.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class AdapterRegistryFactory implements ServiceImplementationFactory
  {
      private ClassFactory _classFactory;
  
      public Object createCoreServiceImplementation(
              ServiceImplementationFactoryParameters factoryParameters)
      {
          AdapterRegistry ar = new AdapterRegistryImpl();
  
          buildAdapterRegistry(factoryParameters, ar);
  
          Class implClass = buildImplementationClass(factoryParameters);
  
          try
          {
              Constructor c = implClass.getConstructors()[0];
  
              return c.newInstance(new Object[]
              { ar });
          }
          catch (Exception ex)
          {
              throw new ApplicationRuntimeException(ex.getMessage(), HiveMind
                      .getLocation(factoryParameters.getFirstParameter()), ex);
          }
  
      }
  
      // package private for testing purposes
  
      void buildAdapterRegistry(ServiceImplementationFactoryParameters factoryParameters,
              AdapterRegistry ar)
      {
          Class serviceInterface = factoryParameters.getServiceInterface();
  
          AdapterRegistryParameter p = (AdapterRegistryParameter) factoryParameters
                  .getFirstParameter();
  
          List contributions = p.getContributions();
  
          Iterator i = contributions.iterator();
  
          while (i.hasNext())
          {
              AdapterRegistryContribution c = (AdapterRegistryContribution) i.next();
  
              try
              {
                  Object adapter = c.getAdapter();
  
                  if (!serviceInterface.isAssignableFrom(adapter.getClass()))
                      throw new ClassCastException(AdapterMessages.adapterWrongInterface(adapter, c
                              .getRegisterClass(), serviceInterface));
  
                  ar.register(c.getRegisterClass(), adapter);
              }
              catch (Exception ex)
              {
                  factoryParameters.getErrorLog().error(ex.getMessage(), c.getLocation(), ex);
              }
  
          }
  
      }
  
      // package private for testing purposes
  
      private Class buildImplementationClass(ServiceImplementationFactoryParameters factoryParameters)
      {
          String name = ClassFabUtils.generateClassName("AdapterRegistry");
          ClassLoader loader = factoryParameters.getInvokingModule().getClassResolver()
                  .getClassLoader();
  
          return buildImplementationClass(factoryParameters, name, loader);
      }
  
      // package private for testing purposes
  
      Class buildImplementationClass(ServiceImplementationFactoryParameters factoryParameters,
              String name, ClassLoader loader)
      {
          Class serviceInterface = factoryParameters.getServiceInterface();
  
          ClassFab cf = _classFactory.newClass(name, Object.class, loader);
  
          cf.addInterface(serviceInterface);
  
          cf.addField("_adapterRegistry", AdapterRegistry.class);
  
          cf.addConstructor(new Class[]
          { AdapterRegistry.class }, null, "_adapterRegistry = $1;");
  
          // TODO: Should we add a check for $1 == null?
  
          cf.addMethod(Modifier.PRIVATE, new MethodSignature(serviceInterface, "_getAdapter",
                  new Class[]
                  { Object.class }, null), "return (" + serviceInterface.getName()
                  + ") _adapterRegistry.getAdapter($1.getClass());");
  
          MethodIterator i = new MethodIterator(serviceInterface);
  
          while (i.hasNext())
          {
              MethodSignature sig = i.next();
  
              if (proper(sig))
              {
                  addAdaptedMethod(cf, sig);
              }
              else
              {
                  ClassFabUtils.addNoOpMethod(cf, sig);
  
                  factoryParameters.getErrorLog().error(
                          AdapterMessages.improperServiceMethod(sig),
                          HiveMind.getLocation(factoryParameters.getFirstParameter()),
                          null);
              }
  
          }
  
          if (!i.getToString())
              ClassFabUtils.addToStringMethod(cf, AdapterMessages.toString(factoryParameters
                      .getServiceId(), serviceInterface));
  
          return cf.createClass();
      }
  
      private void addAdaptedMethod(ClassFab cf, MethodSignature sig)
      {
          String body = "return ($r) _getAdapter($1)." + sig.getName() + "($$);";
  
          cf.addMethod(Modifier.PUBLIC, sig, body);
      }
  
      /**
       * A "proper" method is one with at least one parameter and whose first parameter is an object
       * (not primitive) type.
       */
  
      private boolean proper(MethodSignature sig)
      {
          Class[] parameterTypes = sig.getParameterTypes();
  
          return parameterTypes != null && parameterTypes.length > 0
                  && !parameterTypes[0].isPrimitive();
      }
  
      public void setClassFactory(ClassFactory classFactory)
      {
          _classFactory = classFactory;
      }
  }
  
  
  1.1                  jakarta-hivemind/library/src/java/org/apache/hivemind/lib/adapter/AdapterRegistryContribution.java
  
  Index: AdapterRegistryContribution.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.lib.adapter;
  
  import org.apache.hivemind.impl.BaseLocatable;
  
  /**
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class AdapterRegistryContribution extends BaseLocatable
  {
      private Class _registerClass;
  
      private Object _adapter;
  
      public Object getAdapter()
      {
          return _adapter;
      }
  
      public void setAdapter(Object adaptor)
      {
          _adapter = adaptor;
      }
  
      public Class getRegisterClass()
      {
          return _registerClass;
      }
  
      public void setRegisterClass(Class registerClass)
      {
          _registerClass = registerClass;
      }
  }
  
  
  1.1                  jakarta-hivemind/library/src/java/org/apache/hivemind/lib/adapter/AdapterRegistryParameter.java
  
  Index: AdapterRegistryParameter.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.lib.adapter;
  
  import java.util.List;
  
  import org.apache.hivemind.impl.BaseLocatable;
  
  /**
   * Parameter value passed to the <code>hivemind.lib.AdaptorRegistryFactory</code> service factory.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class AdapterRegistryParameter extends BaseLocatable
  {
      private List _contributions;
  
      /**
       * List of {@link org.apache.hivemind.lib.adapter.AdapterRegistryContribution}.
       */
      public List getContributions()
      {
          return _contributions;
      }
  
      public void setContributions(List configuration)
      {
          _contributions = configuration;
      }
  }
  
  
  1.2       +2 -2      jakarta-hivemind/library/src/java/org/apache/hivemind/lib/util/UtilMessages.java
  
  Index: UtilMessages.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/src/java/org/apache/hivemind/lib/util/UtilMessages.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UtilMessages.java	5 Nov 2004 15:58:34 -0000	1.1
  +++ UtilMessages.java	7 Nov 2004 12:35:00 -0000	1.2
  @@ -32,8 +32,8 @@
                   .getJavaClassName(subjectClass));
       }
   
  -    public static String adaptorNotFound(Class subjectClass)
  +    public static String adapterNotFound(Class subjectClass)
       {
  -        return _formatter.format("adaptor-not-found", ClassFabUtils.getJavaClassName(subjectClass));
  +        return _formatter.format("adapter-not-found", ClassFabUtils.getJavaClassName(subjectClass));
       }
   }
  
  
  
  1.2       +1 -1      jakarta-hivemind/library/src/java/org/apache/hivemind/lib/util/UtilStrings.properties
  
  Index: UtilStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/src/java/org/apache/hivemind/lib/util/UtilStrings.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UtilStrings.properties	5 Nov 2004 15:58:34 -0000	1.1
  +++ UtilStrings.properties	7 Nov 2004 12:35:00 -0000	1.2
  @@ -14,4 +14,4 @@
   # limitations under the License.
   
   duplicate-registration=A registration for class {0} already exists.
  -adaptor-not-found=Could not find an adaptor for class {0}.
  \ No newline at end of file
  +adapter-not-found=Could not find an adapter for class {0}.
  \ No newline at end of file
  
  
  
  1.1                  jakarta-hivemind/library/src/java/org/apache/hivemind/lib/util/AdapterRegistry.java
  
  Index: AdapterRegistry.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.lib.util;
  
  /**
   * An implementation of the <b>adapter </b> pattern. The adapter pattern allows new functionality to
   * be assigned to an existing class. As implemented here, this is a smart lookup between a
   * particular class (the class to be adapted, called the <em>subject class</em>) and some object
   * instance that can provide the extra functionality (called the <em>adapter</em>). The
   * implementation of the adapter is not relevant to the adapterRegistry class.
   * <p>
   * adapters are registered before they can be used; the registration maps a particular class to an
   * adapter instance. The adapter instance will be used when the subject class matches the registered
   * class, or the subject class inherits from the registered class.
   * <p>
   * This means that a search must be made that walks the inheritance tree (upwards from the subject
   * class) to find a registered mapping.
   * <p>
   * In addition, adapters can be registered against <em>interfaces</em>. Searching of interfaces
   * occurs after searching of classes. The exact order is:
   * <ul>
   * <li>Search for the subject class, then each super-class of the subject class (excluding
   * java.lang.Object)
   * <li>Search interfaces, starting with interfaces implemented by the subject class, continuing
   * with interfaces implemented by the super-classes, then interfaces extended by earlier interfaces
   * (the exact order is a bit fuzzy)
   * <li>Search for a match for java.lang.Object, if any
   * </ul>
   * <p>
   * The first match terminates the search.
   * <p>
   * The AdapterRegistry caches the results of search; a subsequent search for the same subject class
   * will be resolved immediately.
   * <p>
   * AdapterRegistry does a minor tweak of the "natural" inheritance. Normally, the parent class of an
   * object array (i.e., <code>Foo[]</code>) is simply <code>Object</code>, even though you may
   * assign <code>Foo[]</code> to a variable of type <code>Object[]</code>. AdapterRegistry
   * "fixes" this by searching for <code>Object[]</code> as if it was the superclass of any object
   * array. This means that the search path for <code>Foo[]</code> is <code>Foo[]</code>,
   * <code>Object[]</code>, then a couple of interfaces {@link java.lang.Cloneable},
   * {@link java.io.Serializable}, etc. that are implicitily implemented by arrays), and then,
   * finally, <code>Object</code>
   * <p>
   * This tweak doesn't apply to arrays of primitives, since such arrays may <em>not</em> be
   * assigned to <code>Object[]</code>.
   * 
   * @author Howard M. Lewis Ship
   * @see org.apache.hivemind.lib.util.AdapterRegistryImpl
   * @since 1.1
   */
  public interface AdapterRegistry
  {
      /**
       * Registers an adapter for a registration class.
       * 
       * @throws IllegalArgumentException
       *             if an adapter has already been registered for the given class.
       */
      public void register(Class registrationClass, Object adapter);
  
      /**
       * Gets the adapter for the specified subjectClass.
       * 
       * @throws IllegalArgumentException
       *             if no adapter could be found.
       */
      public Object getAdapter(Class subjectClass);
  }
  
  
  1.1                  jakarta-hivemind/library/src/java/org/apache/hivemind/lib/util/AdapterRegistryImpl.java
  
  Index: AdapterRegistryImpl.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.lib.util;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.LinkedList;
  import java.util.Map;
  import java.util.WeakHashMap;
  
  import org.apache.hivemind.Defense;
  import org.apache.hivemind.service.ClassFabUtils;
  
  /**
   * Thread-safe implementation of {@link org.apache.hivemind.lib.util.AdapterRegistry}.
   * 
   * @author Howard Lewis Ship
   * @since 1.1
   */
  
  public class AdapterRegistryImpl implements AdapterRegistry
  {
      /**
       * A Map of adaptor objects, keyed on registration Class.
       */
  
      private Map _registrations = new HashMap();
  
      /**
       * A Map of adaptor objects, keyed on subject Class.
       */
  
      private Map _cache = new WeakHashMap();
  
      public synchronized void register(Class registrationClass, Object adaptor)
      {
          Defense.notNull(registrationClass, "registrationClass");
          Defense.notNull(adaptor, "adaptor");
  
          if (_registrations.containsKey(registrationClass))
              throw new IllegalArgumentException(UtilMessages
                      .duplicateRegistration(registrationClass));
  
          _registrations.put(registrationClass, adaptor);
  
          // Can't tell what is and isn't valid in the cache.
          // Also, normally all registrations occur before any adaptors
          // are searched for, so this is not a big deal.
  
          _cache.clear();
      }
  
      public synchronized Object getAdapter(Class subjectClass)
      {
          Defense.notNull(subjectClass, "subjectClass");
  
          Object result = _cache.get(subjectClass);
  
          if (result != null)
              return result;
  
          result = searchForAdaptor(subjectClass);
  
          // Record the result in the cache
  
          _cache.put(subjectClass, result);
  
          return result;
      }
  
      /**
       * Searches the registration Map for a match, based on inheritance.
       * <p>
       * Searches class inheritance first, then interfaces (in a rather vague order). Really should
       * match the order from the JVM spec.
       * <p>
       * There's a degenerate case where we may check the same interface more than once:
       * <ul>
       * <li>Two interfaces, I1 and I2
       * <li>Two classes, C1 and C2
       * <li>I2 extends I1
       * <li>C2 extends C1
       * <li>C1 implements I1
       * <li>C2 implements I2
       * <li>The search will be: C2, C1, I2, I1, I1
       * <li>I1 is searched twice, because C1 implements it, and I2 extends it
       * <li>There are other such cases, but none of them cause infinite loops and most are rare (we
       * could guard against it, but its relatively expensive).
       * <li>Multiple checks only occur if we don't find a registration
       * </ul>
       * <p>
       * This method is only called from a synchronized block, so it is implicitly synchronized.
       */
  
      private Object searchForAdaptor(Class subjectClass)
      {
          LinkedList queue = null;
          Object result = null;
  
          // Step one: work up through the class inheritance.
  
          Class searchClass = subjectClass;
  
          // Primitive types have null, not Object, as their parent
          // class.
  
          while (searchClass != Object.class && searchClass != null)
          {
              result = _registrations.get(searchClass);
              if (result != null)
                  return result;
  
              // Not an exact match. If the search class
              // implements any interfaces, add them to the queue.
  
              Class[] interfaces = searchClass.getInterfaces();
              int length = interfaces.length;
  
              if (queue == null && length > 0)
                  queue = new LinkedList();
  
              for (int i = 0; i < length; i++)
                  queue.addLast(interfaces[i]);
  
              // Advance up to the next superclass
  
              searchClass = getSuperclass(searchClass);
  
          }
  
          // Ok, the easy part failed, lets start searching
          // interfaces.
  
          if (queue != null)
          {
              while (!queue.isEmpty())
              {
                  searchClass = (Class) queue.removeFirst();
  
                  result = _registrations.get(searchClass);
                  if (result != null)
                      return result;
  
                  // Interfaces can extend other interfaces; add them
                  // to the queue.
  
                  Class[] interfaces = searchClass.getInterfaces();
                  int length = interfaces.length;
  
                  for (int i = 0; i < length; i++)
                      queue.addLast(interfaces[i]);
              }
          }
  
          // Not a match on interface; our last gasp is to check
          // for a registration for java.lang.Object
  
          result = _registrations.get(Object.class);
          if (result != null)
              return result;
  
          // No match? That's rare ... and an error.
  
          throw new IllegalArgumentException(UtilMessages.adapterNotFound(subjectClass));
      }
  
      /**
       * Returns the superclass of the given class, with a single tweak: If the search class is an
       * array class, and the component type is an object class (but not Object), then the simple
       * Object array class is returned. This reflects the fact that an array of any class may be
       * assignable to <code>Object[]</code>, even though the superclass of an array is always
       * simply <code>Object</code>.
       */
  
      private Class getSuperclass(Class searchClass)
      {
          if (searchClass.isArray())
          {
              Class componentType = searchClass.getComponentType();
  
              if (!componentType.isPrimitive() && componentType != Object.class)
                  return Object[].class;
          }
  
          return searchClass.getSuperclass();
      }
  
      public synchronized String toString()
      {
          StringBuffer buffer = new StringBuffer();
          buffer.append("AdaptorRegistry[");
  
          Iterator i = _registrations.entrySet().iterator();
          boolean showSep = false;
  
          while (i.hasNext())
          {
              if (showSep)
                  buffer.append(' ');
  
              Map.Entry entry = (Map.Entry) i.next();
  
              Class registeredClass = (Class) entry.getKey();
  
              buffer.append(ClassFabUtils.getJavaClassName(registeredClass));
              buffer.append("=");
              buffer.append(entry.getValue());
  
              showSep = true;
          }
  
          buffer.append("]");
  
          return buffer.toString();
      }
  }
  
  
  1.1                  jakarta-hivemind/library/src/documentation/content/xdocs/hivemind-lib/AdapterRegistryFactory.xml
  
  Index: AdapterRegistryFactory.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     Copyright 2004 The Apache Software Foundation
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.3//EN" 
    "http://xml.apache.org/forrest/dtd/document-v13.dtd" [
    <!ENTITY projectroot '../'>
    <!ENTITY % common-links SYSTEM "../links.ent">
    %common-links;
    ]>
  <document>
    <header>
      <title>hivemind.lib.AdapterRegistryFactory Service</title>
    </header>
    <body>
      <p>The <link href="&hivedoc;/service/hivemind.lib.AdapterRegistryFactory.html"> 
        AdapterRegistryFactory</link> service is used to create a service implementation
        based on a service interface and a number of <em>adapters</em> implementing that interface.</p>
        <p>
          The class of the first parameter of each method is used to select the correct adapter to
          delegate the method invocation to.  
        </p>
        <p>
          The class-to-adapter lookup understands inheritance. If an exact match for a class is not found,
          then the search works up the inheritance chain.  First, it checks all the super-classes, working upwards,
          but skipping java.lang.Object. It then searches all the interfaces directly or indirectly implemented by
          the search class.  Finally, java.lang.Object is checked.  It is an exception if no match is found (so you should
          almost always include an adapter for java.lang.Object).
        </p>
        
        
      <section>
        <title>Usage</title>
        <p> The factory expects a single parameter element: </p>
        <source><![CDATA[
  <construct configuration-id="..."/>]]></source>
        <p>The <code>configuration-id</code> is the id of the companion 
          configuration (used to define classes and adapters).</p>
      </section>
      <section>
        <title>Configuration</title>
        <p>Each AdapterRegistry service must have a configuration, into which adapters 
          are contributed:</p>
        <source><![CDATA[
  <configuration-point id="..." schema-id="hivemind.lib.AdapterRegistry"/>]]></source>
      </section>
      <section>
        <title>Contributions</title>
        <p>Contributions into the configuration are used to specify classes to match, and the adapters to use.</p>
        <section>
          <title>adapter</title>
          <source><![CDATA[
  <adapter class="..." object="..."/>]]> </source>
          <p>Contributes an adapter. The <code>class</code> attribute defines the class to match against, the 
            <code>object</code> attribute provides the actual adapter object (which must implement the service 
            interface). </p>
        </section>
      </section>
    </body>
  </document>
  
  
  1.1                  jakarta-hivemind/library/src/test/org/apache/hivemind/lib/adapter/AdapterFactoryIntegration.xml
  
  Index: AdapterFactoryIntegration.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     Copyright 2004 The Apache Software Foundation
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <module id="hivemind.lib.test" version="1.0.0">
    
    <configuration-point id="ToStringAdapters" schema-id="hivemind.lib.AdapterRegistry"/>
    
    <contribution configuration-id="ToStringAdapters">
      
      <adapter class="java.lang.Object" object="instance:org.apache.hivemind.lib.adapter.CatchAllToStringAdapter"/>
      
    </contribution>
    
    <service-point id="ToStringAdapter" interface="org.apache.hivemind.lib.adapter.ToStringAdapter">
      <invoke-factory service-id="hivemind.lib.AdapterRegistryFactory">
        <construct configuration-id="ToStringAdapters"/>
      </invoke-factory>
    </service-point>
    
  </module>
  
  
  1.1                  jakarta-hivemind/library/src/test/org/apache/hivemind/lib/adapter/CatchAllToStringAdapter.java
  
  Index: CatchAllToStringAdapter.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.lib.adapter;
  
  /**
   * Used by {@link org.apache.hivemind.lib.util.TestAdaptorRegistry}'s integration test.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class CatchAllToStringAdapter implements ToStringAdapter
  {
  
      /**
       * Invokes {@link java.lang.Object#toString()}.
       */
  
      public String toString(Object o)
      {
          return o.toString();
      }
  
  }
  
  
  1.1                  jakarta-hivemind/library/src/test/org/apache/hivemind/lib/adapter/ToStringAdapter.java
  
  Index: ToStringAdapter.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.lib.adapter;
  
  /**
   * Used by {@link org.apache.hivemind.lib.adapter.TestAdapterRegistryFactory}.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public interface ToStringAdapter
  {
      public String toString(Object o);
  }
  
  
  1.1                  jakarta-hivemind/library/src/test/org/apache/hivemind/lib/adapter/TestAdapterRegistryFactory.java
  
  Index: TestAdapterRegistryFactory.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.lib.adapter;
  
  import java.lang.reflect.Modifier;
  import java.util.Collections;
  import java.util.List;
  
  import org.apache.hivemind.ErrorLog;
  import org.apache.hivemind.Location;
  import org.apache.hivemind.Registry;
  import org.apache.hivemind.ServiceImplementationFactoryParameters;
  import org.apache.hivemind.lib.adapter.AdapterMessages;
  import org.apache.hivemind.lib.adapter.AdapterRegistryContribution;
  import org.apache.hivemind.lib.adapter.AdapterRegistryFactory;
  import org.apache.hivemind.lib.adapter.AdapterRegistryParameter;
  import org.apache.hivemind.lib.util.AdapterRegistry;
  import org.apache.hivemind.service.ClassFab;
  import org.apache.hivemind.service.ClassFabUtils;
  import org.apache.hivemind.service.ClassFactory;
  import org.apache.hivemind.service.MethodFab;
  import org.apache.hivemind.service.MethodSignature;
  import org.apache.hivemind.test.AggregateArgumentsMatcher;
  import org.apache.hivemind.test.ArgumentMatcher;
  import org.apache.hivemind.test.ArrayMatcher;
  import org.apache.hivemind.test.HiveMindTestCase;
  import org.apache.hivemind.test.TypeMatcher;
  import org.easymock.MockControl;
  
  /**
   * Test for the {@link org.apache.hivemind.lib.adapter.AdapterRegistryFactory}service
   * implementation factory.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class TestAdapterRegistryFactory extends HiveMindTestCase
  {
      private List buildContributions(Class registerClass, Object adapter, Location location)
      {
          AdapterRegistryContribution c = new AdapterRegistryContribution();
  
          c.setRegisterClass(registerClass);
          c.setAdapter(adapter);
          c.setLocation(location);
  
          return Collections.singletonList(c);
      }
  
      private AdapterRegistryParameter buildParameter(Class registerClass, Object adapter,
              Location contributionLocation, Location parameterLocation)
      {
          AdapterRegistryParameter result = new AdapterRegistryParameter();
  
          result.setContributions(buildContributions(registerClass, adapter, contributionLocation));
          result.setLocation(parameterLocation);
  
          return result;
      }
  
      private AdapterRegistryParameter buildParameter(Class registerClass, Object adapter)
      {
          return buildParameter(registerClass, adapter, null, null);
      }
  
      public void testBuildRegistry()
      {
          AdapterRegistry ar = (AdapterRegistry) newMock(AdapterRegistry.class);
          ToStringAdapter adapter = (ToStringAdapter) newMock(ToStringAdapter.class);
  
          MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
          ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters) fpc
                  .getMock();
  
          fp.getServiceInterface();
          fpc.setReturnValue(ToStringAdapter.class);
  
          AdapterRegistryParameter p = buildParameter(Number.class, adapter);
  
          fp.getFirstParameter();
          fpc.setReturnValue(p);
  
          ar.register(Number.class, adapter);
  
          replayControls();
  
          new AdapterRegistryFactory().buildAdapterRegistry(fp, ar);
  
          verifyControls();
      }
  
      public void testBuildRegistryWrongAdapterType()
      {
          Location l = fabricateLocation(3);
  
          AdapterRegistry ar = (AdapterRegistry) newMock(AdapterRegistry.class);
          ToStringAdapter adapter = (ToStringAdapter) newMock(ToStringAdapter.class);
  
          MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
          ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters) fpc
                  .getMock();
  
          MockControl logc = newControl(ErrorLog.class);
          ErrorLog log = (ErrorLog) logc.getMock();
  
          fp.getServiceInterface();
          fpc.setReturnValue(Runnable.class);
  
          AdapterRegistryParameter p = buildParameter(Number.class, adapter, l, null);
  
          fp.getFirstParameter();
          fpc.setReturnValue(p);
  
          fp.getErrorLog();
          fpc.setReturnValue(log);
  
          log.error(
                  AdapterMessages.adapterWrongInterface(adapter, Number.class, Runnable.class),
                  l,
                  new ClassCastException());
          logc.setMatcher(new AggregateArgumentsMatcher(new ArgumentMatcher[]
          { null, null, new TypeMatcher() }));
  
          replayControls();
  
          new AdapterRegistryFactory().buildAdapterRegistry(fp, ar);
  
          verifyControls();
      }
  
      public void testBuildImplementationClass()
      {
          MockControl factoryControl = newControl(ClassFactory.class);
          ClassFactory factory = (ClassFactory) factoryControl.getMock();
  
          MockControl cfc = newControl(ClassFab.class);
          ClassFab cf = (ClassFab) cfc.getMock();
  
          MethodFab mf = (MethodFab) newMock(MethodFab.class);
  
          ClassLoader loader = Thread.currentThread().getContextClassLoader();
  
          MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
          ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters) fpc
                  .getMock();
  
          fp.getServiceInterface();
          fpc.setReturnValue(ToStringAdapter.class);
  
          factory.newClass("NewClass", Object.class, loader);
          factoryControl.setReturnValue(cf);
  
          cf.addInterface(ToStringAdapter.class);
          cf.addField("_adapterRegistry", AdapterRegistry.class);
  
          cf.addConstructor(new Class[]
          { AdapterRegistry.class }, null, "_adapterRegistry = $1;");
          cfc.setMatcher(new AggregateArgumentsMatcher(new ArrayMatcher()));
  
          cf
                  .addMethod(
                          Modifier.PRIVATE,
                          new MethodSignature(ToStringAdapter.class, "_getAdapter", new Class[]
                          { Object.class }, null),
                          "return (org.apache.hivemind.lib.adapter.ToStringAdapter) _adapterRegistry.getAdapter($1.getClass());");
          cfc.setReturnValue(mf);
  
          cf.addMethod(Modifier.PUBLIC, new MethodSignature(String.class, "toString", new Class[]
          { Object.class }, null), "return ($r) _getAdapter($1).toString($$);");
          cfc.setReturnValue(mf);
  
          fp.getServiceId();
          fpc.setReturnValue("foo.Bar");
  
          ClassFabUtils.addToStringMethod(cf, AdapterMessages.toString(
                  "foo.Bar",
                  ToStringAdapter.class));
          cfc.setReturnValue(mf);
  
          cf.createClass();
          cfc.setReturnValue(String.class);
  
          replayControls();
  
          AdapterRegistryFactory f = new AdapterRegistryFactory();
          f.setClassFactory(factory);
  
          f.buildImplementationClass(fp, "NewClass", loader);
  
          verifyControls();
      }
  
      public void testBuildImplementationClassImproperMethod()
      {
          Location l = fabricateLocation(31);
  
          MockControl factoryControl = newControl(ClassFactory.class);
          ClassFactory factory = (ClassFactory) factoryControl.getMock();
  
          MockControl cfc = newControl(ClassFab.class);
          ClassFab cf = (ClassFab) cfc.getMock();
  
          MethodFab mf = (MethodFab) newMock(MethodFab.class);
  
          ClassLoader loader = Thread.currentThread().getContextClassLoader();
  
          MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
          ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters) fpc
                  .getMock();
  
          ErrorLog log = (ErrorLog) newMock(ErrorLog.class);
  
          fp.getServiceInterface();
          fpc.setReturnValue(Runnable.class);
  
          factory.newClass("NewClass", Object.class, loader);
          factoryControl.setReturnValue(cf);
  
          cf.addInterface(Runnable.class);
          cf.addField("_adapterRegistry", AdapterRegistry.class);
  
          cf.addConstructor(new Class[]
          { AdapterRegistry.class }, null, "_adapterRegistry = $1;");
          cfc.setMatcher(new AggregateArgumentsMatcher(new ArrayMatcher()));
  
          cf.addMethod(
                  Modifier.PRIVATE,
                  new MethodSignature(Runnable.class, "_getAdapter", new Class[]
                  { Object.class }, null),
                  "return (java.lang.Runnable) _adapterRegistry.getAdapter($1.getClass());");
          cfc.setReturnValue(mf);
  
          MethodSignature sig = new MethodSignature(void.class, "run", null, null);
  
          cf.addMethod(Modifier.PUBLIC, sig, "{  }");
          cfc.setReturnValue(mf);
  
          fp.getErrorLog();
          fpc.setReturnValue(log);
  
          fp.getFirstParameter();
          // Slight fudge: we return the location itself when we should return
          // an object with this location.
          fpc.setReturnValue(l);
  
          log.error(AdapterMessages.improperServiceMethod(sig), l, null);
  
          fp.getServiceId();
          fpc.setReturnValue("foo.Bar");
  
          ClassFabUtils.addToStringMethod(cf, AdapterMessages.toString("foo.Bar", Runnable.class));
          cfc.setReturnValue(mf);
  
          cf.createClass();
  
          cfc.setReturnValue(String.class);
  
          replayControls();
  
          AdapterRegistryFactory f = new AdapterRegistryFactory();
          f.setClassFactory(factory);
  
          f.buildImplementationClass(fp, "NewClass", loader);
  
          verifyControls();
      }
  
      public void testIntegration() throws Exception
      {
          Registry r = buildFrameworkRegistry("AdapterFactoryIntegration.xml");
  
          ToStringAdapter ts = (ToStringAdapter) r.getService(ToStringAdapter.class);
  
          assertEquals("5150", ts.toString(new Integer(5150)));
      }
  }
  
  
  1.32      +1 -1      jakarta-hivemind/src/documentation/content/xdocs/site.xml
  
  Index: site.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/src/documentation/content/xdocs/site.xml,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- site.xml	5 Nov 2004 15:58:34 -0000	1.31
  +++ site.xml	7 Nov 2004 12:35:01 -0000	1.32
  @@ -107,7 +107,7 @@
   		<index href="hivemind-lib/index.html" tab="hivemind-lib"/>
   		
   		<services label="Services" tab="hivemind-lib">
  -      <hivemind.lib.AdaptorRegistryFactory label="AdaptorRegistryFactory" href="hivemind-lib/AdaptorRegistryFactory.html"/>
  +      <hivemind.lib.AdapterRegistryFactory label="AdapterRegistryFactory" href="hivemind-lib/AdapterRegistryFactory.html"/>
         <hivemind.lib.BeanFactoryBuilder label="BeanFactoryBuilder" href="hivemind-lib/BeanFactoryBuilder.html"/>
         <hivemind.lib.DefaultImplementationBuilder label="DefaultImplementationBuilder" href="hivemind-lib/DefaultImplementationBuilder.html"/>
   			<hivemind.lib.EJBProxyFactory label="EJBProxyFactory" href="hivemind-lib/EJBProxyFactory.html"/>
  
  
  
  1.16      +16 -16    jakarta-hivemind/library/src/descriptor/META-INF/hivemodule.xml
  
  Index: hivemodule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/src/descriptor/META-INF/hivemodule.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- hivemodule.xml	5 Nov 2004 15:58:35 -0000	1.15
  +++ hivemodule.xml	7 Nov 2004 12:35:01 -0000	1.16
  @@ -292,38 +292,38 @@
     </service-point>
     
     
  -  <schema id="AdaptorRegistry">
  +  <schema id="AdapterRegistry">
       
  -    Used with the hivemind.lib.AdaptorRegistryFactory to define a set of classes and corresponding
  -    adaptors.
  +    Used with the hivemind.lib.AdapterRegistryFactory to define a set of classes and corresponding
  +    adapters.
       
  -    <element name="adaptor">
  +    <element name="adapter">
         
         <attribute name="class" translator="class" required="true">
  -        The class (or interface) to register the adaptor against.
  +        The class (or interface) to register the adapter against.
         </attribute>
         
         <attribute name="object" translator="object" required="true">
  -        The adaptor that corresponds to objects of the given class.
  +        The adapter that corresponds to objects of the given class.
         </attribute>
         
  -      <conversion class="org.apache.hivemind.lib.adaptor.AdaptorRegistryContribution">
  +      <conversion class="org.apache.hivemind.lib.adapter.AdapterRegistryContribution">
           <map attribute="class" property="registerClass"/>
  -        <map attribute="object" property="adaptor"/>
  +        <map attribute="object" property="adapter"/>
         </conversion>
         
       </element>
       
     </schema>
     
  -  <service-point id="AdaptorRegistryFactory" interface="org.apache.hivemind.ServiceImplementationFactory">
  +  <service-point id="AdapterRegistryFactory" interface="org.apache.hivemind.ServiceImplementationFactory">
       
  -    Creates a service as a wrapper around an AdaptorRegistry.  The first parameter to
  -    each method of the service interface is used to select an adaptor, and then
  -    the method implementation delegates to that adaptor.
  +    Creates a service as a wrapper around an AdapterRegistry.  The first parameter to
  +    each method of the service interface is used to select an adapter, and then
  +    the method implementation delegates to that adapter.
       
       <invoke-factory>
  -      <construct class="org.apache.hivemind.lib.adaptor.AdaptorRegistryFactory">
  +      <construct class="org.apache.hivemind.lib.adapter.AdapterRegistryFactory">
           <set-service property="classFactory" service-id="hivemind.ClassFactory"/>
         </construct>
       </invoke-factory>
  @@ -331,11 +331,11 @@
       <parameters-schema>
         <element name="construct">
           <attribute name="configuration-id" translator="configuration" required="true">
  -          A configuration utilizing the hivemind.lib.AdaptorRegistry schema, which
  -          defines the classes and matching adaptors.
  +          A configuration utilizing the hivemind.lib.AdapterRegistry schema, which
  +          defines the classes and matching adapters.
           </attribute>
           
  -        <conversion class="org.apache.hivemind.lib.adaptor.AdaptorRegistryParameter">
  +        <conversion class="org.apache.hivemind.lib.adapter.AdapterRegistryParameter">
             <map attribute="configuration-id" property="contributions"/>
           </conversion>
         </element>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message