You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemind.apache.org by hl...@apache.org on 2005/02/11 19:15:21 UTC

cvs commit: jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl ClassObjectProvider.java ObjectTranslator.java

hlship      2005/02/11 10:15:21

  Modified:    framework/src/descriptor/META-INF hivemodule.xml
               framework/src/documentation/content/xdocs/hivemind
                        ObjectProviders.xml ThreadLocalStorage.xml
               framework/src/test/org/apache/hivemind/service/impl
                        TestObjectProviders.java
               .        status.xml
               framework/src/java/org/apache/hivemind/service/impl
                        ObjectTranslator.java
  Added:       framework/src/java/org/apache/hivemind/service/impl
                        ClassObjectProvider.java
  Log:
  Add class: object provider prefix.
  
  Revision  Changes    Path
  1.24      +8 -0      jakarta-hivemind/framework/src/descriptor/META-INF/hivemodule.xml
  
  Index: hivemodule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/descriptor/META-INF/hivemodule.xml,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- hivemodule.xml	11 Feb 2005 15:29:52 -0000	1.23
  +++ hivemodule.xml	11 Feb 2005 18:15:20 -0000	1.24
  @@ -694,11 +694,19 @@
       <create-instance class="service.impl.ServicePropertyObjectProvider"/>
     </service-point>
     
  +  <service-point id="ClassObjectProvider" interface="org.apache.hivemind.service.ObjectProvider"  visibility="private">
  +    
  +    ObjectProvider that can find Class objects Mapped to the class: prefix.
  +      
  +    <create-instance class="service.impl.ClassObjectProvider"/>
  +  </service-point>  
  +  
     <contribution configuration-id="ObjectProviders">
       <provider prefix="service" service-id="ServiceObjectProvider"/>
       <provider prefix="configuration" service-id="ConfigurationObjectProvider"/>
       <provider prefix="instance" service-id="ObjectInstanceObjectProvider"/>
       <provider prefix="service-property" service-id="ServicePropertyObjectProvider"/>
  +    <provider prefix="class" service-id="ClassObjectProvider"/>
     </contribution>
     
     <service-point id="ThreadLocale" interface="org.apache.hivemind.service.ThreadLocale">
  
  
  
  1.10      +8 -0      jakarta-hivemind/framework/src/documentation/content/xdocs/hivemind/ObjectProviders.xml
  
  Index: ObjectProviders.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/documentation/content/xdocs/hivemind/ObjectProviders.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ObjectProviders.xml	5 Jan 2005 21:53:29 -0000	1.9
  +++ ObjectProviders.xml	11 Feb 2005 18:15:21 -0000	1.10
  @@ -69,6 +69,14 @@
             bean:ValidatorFactory:string,required
           </td>
       </tr>
  +    
  +    <tr>
  +      <td>class</td>
  +      <td>The locator is a class name. It may be a partial class name, with the package name
  +        provided by the contributing module.</td>
  +        <td>class:java.util.List</td>
  +    </tr>
  +    
       <tr>
         <td>configuration</td>
         <td>The locator is the id of a configuration.</td>
  
  
  
  1.8       +1 -0      jakarta-hivemind/framework/src/documentation/content/xdocs/hivemind/ThreadLocalStorage.xml
  
  Index: ThreadLocalStorage.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/documentation/content/xdocs/hivemind/ThreadLocalStorage.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ThreadLocalStorage.xml	11 Feb 2005 15:29:51 -0000	1.7
  +++ ThreadLocalStorage.xml	11 Feb 2005 18:15:21 -0000	1.8
  @@ -14,6 +14,7 @@
      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">
  
  
  
  1.7       +19 -0     jakarta-hivemind/framework/src/test/org/apache/hivemind/service/impl/TestObjectProviders.java
  
  Index: TestObjectProviders.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/service/impl/TestObjectProviders.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestObjectProviders.java	10 Feb 2005 01:04:35 -0000	1.6
  +++ TestObjectProviders.java	11 Feb 2005 18:15:21 -0000	1.7
  @@ -166,5 +166,24 @@
           }
       }
   
  +    public void testClassProvider()
  +    {
  +        MockControl control = newControl(Module.class);
  +        Module module = (Module) control.getMock();
  +
  +        module.resolveType("List");
  +        control.setReturnValue(List.class);
  +
  +        replayControls();
  +
  +        assertSame(List.class, new ClassObjectProvider().provideObject(
  +                module,
  +                Class.class,
  +                "List",
  +                null));
  +
  +        verifyControls();
  +    }
  +
       // TODO: Integration test that proves the XML is valid.
   }
  \ No newline at end of file
  
  
  
  1.98      +1 -0      jakarta-hivemind/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/status.xml,v
  retrieving revision 1.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- status.xml	11 Feb 2005 15:29:52 -0000	1.97
  +++ status.xml	11 Feb 2005 18:15:21 -0000	1.98
  @@ -34,6 +34,7 @@
         <action type="fix" dev="KW" fixes-bug="HIVEMIND-88" due-to="Brian K. Wallace"> Error running examples using Ant targets. </action>
         <action type="update" dev="HLS"> Add package attribute to &lt;module&gt; and automatically qualify Java class and interface names into that package. </action>
         <action type="update" dev="HLS"> Allow the locale to be changed. </action>
  +      <action type="update" dev="HLS"> Add class: object provider (for resolving classes). </action>
       </release>
       <release version="1.1-alpha-1" date="Jan 19 2005">
         <action type="add" dev="KW"> Added &lt;dependency&gt; construct providing support for dependencies between modules. Refactoring of RegistryBuilder: Now constructs Registry using a ModuleProvider. </action>
  
  
  
  1.7       +9 -1      jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ObjectTranslator.java
  
  Index: ObjectTranslator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ObjectTranslator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ObjectTranslator.java	5 Jan 2005 18:05:01 -0000	1.6
  +++ ObjectTranslator.java	11 Feb 2005 18:15:21 -0000	1.7
  @@ -17,6 +17,7 @@
   import java.util.HashMap;
   import java.util.Map;
   
  +import org.apache.hivemind.ApplicationRuntimeException;
   import org.apache.hivemind.ErrorLog;
   import org.apache.hivemind.HiveMind;
   import org.apache.hivemind.Location;
  @@ -69,7 +70,14 @@
   
           String locator = inputValue.substring(colonx + 1);
   
  -        return provider.provideObject(contributingModule, propertyType, locator, location);
  +        try
  +        {
  +            return provider.provideObject(contributingModule, propertyType, locator, location);
  +        }
  +        catch (Exception ex)
  +        {
  +            throw new ApplicationRuntimeException(ex.getMessage(), location, ex);
  +        }
   
       }
   
  
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ClassObjectProvider.java
  
  Index: ClassObjectProvider.java
  ===================================================================
  // Copyright 2005 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.service.impl;
  
  import org.apache.hivemind.Location;
  import org.apache.hivemind.internal.Module;
  import org.apache.hivemind.service.ObjectProvider;
  
  /**
   * Implementation of {@link org.apache.hivemind.service.ObjectProvider}that interprets the locator
   * as a class name and converts it to a Class object. The namemay be partial; it is interpreted
   * using the contributing module's package name.  Mapped to the "class:" prefix.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class ClassObjectProvider implements ObjectProvider
  {
  
      public Object provideObject(Module contributingModule, Class propertyType, String locator,
              Location location)
      {
          return contributingModule.resolveType(locator);
      }
  
  }
  
  

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