hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject svn commit: r190895 - in /jakarta/hivemind/trunk/framework/src: descriptor/META-INF/ java/org/apache/hivemind/schema/rules/ java/org/apache/hivemind/service/impl/ test/org/apache/hivemind/service/impl/
Date Thu, 16 Jun 2005 10:56:32 GMT
Author: knut
Date: Thu Jun 16 03:56:29 2005
New Revision: 190895

URL: http://svn.apache.org/viewcvs?rev=190895&view=rev
Log:
modifications to fix HIVEMIND-124:
 - BuilderFactory's <string> constructor parameter element now uses NullTranslator
 - BuilderPropertyFacet#isAssignableToType() passes on encountered Exceptions
 - ServiceObjectProvider now works like ServiceTranslator

Modified:
    jakarta/hivemind/trunk/framework/src/descriptor/META-INF/hivemodule.xml
    jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/schema/rules/NullTranslator.java
    jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/impl/BuilderPropertyFacet.java
    jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/impl/ServiceObjectProvider.java
    jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/service/impl/TestBuilderPropertyFacet.java
    jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/service/impl/TestObjectProviders.java

Modified: jakarta/hivemind/trunk/framework/src/descriptor/META-INF/hivemodule.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/framework/src/descriptor/META-INF/hivemodule.xml?rev=190895&r1=190894&r2=190895&view=diff
==============================================================================
--- jakarta/hivemind/trunk/framework/src/descriptor/META-INF/hivemodule.xml (original)
+++ jakarta/hivemind/trunk/framework/src/descriptor/META-INF/hivemodule.xml Thu Jun 16 03:56:29
2005
@@ -219,7 +219,7 @@
           
           <rules>
             <create-object class="service.impl.BuilderPropertyFacet"/>
-            <set-property property="translator" value="smart"/>
+            <set-property property="translator" value="null"/>
             <read-content property="value"/>
             <invoke-parent depth="7" method="addParameter"/>
           </rules>
@@ -553,6 +553,7 @@
     <translator class="schema.rules.QualifiedIdTranslator" name="qualified-id"/>
     <translator class="schema.rules.IdListTranslator" name="id-list"/>
     <translator name="object" service-id="ObjectTranslator"/>
+    <translator class="schema.rules.NullTranslator" name="null"/>
   </contribution>
   
   <service-point id="ShutdownCoordinator">

Modified: jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/schema/rules/NullTranslator.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/schema/rules/NullTranslator.java?rev=190895&r1=190894&r2=190895&view=diff
==============================================================================
--- jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/schema/rules/NullTranslator.java
(original)
+++ jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/schema/rules/NullTranslator.java
Thu Jun 16 03:56:29 2005
@@ -19,22 +19,18 @@
 import org.apache.hivemind.schema.Translator;
 
 /**
- * A translator that does nothing. Used in cases where no translator is supplied.
+ * A translator that returns the input value itself. Used by the BuilderFactory's &lt;string&gt;
+ * constructor argument element.
  * 
- * TODO: Verify that this actually used (I believe the SmartTranslator is now the default
case).
- *
  * @author Howard Lewis Ship
  */
 public class NullTranslator implements Translator
 {
     /**
-     * Returns the inputValue. 
+     * Returns the inputValue.
      */
-    public Object translate(
-        Module contributingModule,
-        Class propertyType,
-        String inputValue,
-        Location location)
+    public Object translate(Module contributingModule, Class propertyType, String inputValue,
+            Location location)
     {
         return inputValue;
     }

Modified: jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/impl/BuilderPropertyFacet.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/impl/BuilderPropertyFacet.java?rev=190895&r1=190894&r2=190895&view=diff
==============================================================================
--- jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/impl/BuilderPropertyFacet.java
(original)
+++ jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/impl/BuilderPropertyFacet.java
Thu Jun 16 03:56:29 2005
@@ -17,8 +17,9 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.hivemind.Location;
 import org.apache.hivemind.ServiceImplementationFactoryParameters;
+import org.apache.hivemind.internal.Module;
 import org.apache.hivemind.schema.Translator;
 import org.apache.hivemind.util.ConstructorUtils;
 
@@ -66,20 +67,13 @@
     public boolean isAssignableToType(ServiceImplementationFactoryParameters factoryParameters,
             Class targetType)
     {
-        try
-        {
-            // TODO should Translator declare an analoguous isAssignableToType method?
-            Object facetValue = getFacetValue(factoryParameters, targetType);
+        // TODO should Translator declare an analoguous isAssignableToType method?
+        Object facetValue = getFacetValue(factoryParameters, targetType);
 
-            if (facetValue == null)
-                return !targetType.isPrimitive();
+        if (facetValue == null)
+            return !targetType.isPrimitive();
 
-            return ConstructorUtils.isCompatible(targetType, facetValue.getClass());
-        }
-        catch (ApplicationRuntimeException e)
-        {
-            return false;
-        }
+        return ConstructorUtils.isCompatible(targetType, facetValue.getClass());
     }
 
     /** @since 1.1 */

Modified: jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/impl/ServiceObjectProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/impl/ServiceObjectProvider.java?rev=190895&r1=190894&r2=190895&view=diff
==============================================================================
--- jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/impl/ServiceObjectProvider.java
(original)
+++ jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/impl/ServiceObjectProvider.java
Thu Jun 16 03:56:29 2005
@@ -37,7 +37,7 @@
         if (HiveMind.isBlank(locator))
             return null;
 
-        return contributingModule.getService(locator, propertyType);
+        return contributingModule.getService(locator, Object.class);
     }
 
 }

Modified: jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/service/impl/TestBuilderPropertyFacet.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/service/impl/TestBuilderPropertyFacet.java?rev=190895&r1=190894&r2=190895&view=diff
==============================================================================
--- jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/service/impl/TestBuilderPropertyFacet.java
(original)
+++ jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/service/impl/TestBuilderPropertyFacet.java
Thu Jun 16 03:56:29 2005
@@ -14,6 +14,7 @@
 
 package org.apache.hivemind.service.impl;
 
+import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.ServiceImplementationFactoryParameters;
 import org.apache.hivemind.internal.Module;
 import org.apache.hivemind.schema.Translator;
@@ -52,6 +53,48 @@
 
         facet.isAssignableToType(params, Object.class);
         facet.getFacetValue(params, Object.class);
+
+        verifyControls();
+    }
+
+    public void testAssignableFromBadValue()
+    {
+        MockControl moduleControl = newControl(Module.class);
+        Module module = (Module) moduleControl.getMock();
+
+        MockControl translatorControl = newControl(Translator.class);
+        Translator translator = (Translator) translatorControl.getMock();
+
+        MockControl paramsControl = newControl(ServiceImplementationFactoryParameters.class);
+        ServiceImplementationFactoryParameters params = (ServiceImplementationFactoryParameters)
paramsControl
+                .getMock();
+
+        BuilderPropertyFacet facet = new BuilderPropertyFacet();
+
+        facet.setTranslator("foo");
+        facet.setValue("bar");
+
+        params.getInvokingModule();
+        paramsControl.setDefaultReturnValue(module);
+
+        module.getTranslator("foo");
+        moduleControl.setDefaultReturnValue(translator);
+
+        translator.translate(module, Object.class, "bar", null);
+        ApplicationRuntimeException exception = new ApplicationRuntimeException("");
+        translatorControl.setThrowable(exception);
+
+        replayControls();
+
+        try
+        {
+            facet.isAssignableToType(params, Object.class);
+            unreachable();
+        }
+        catch (ApplicationRuntimeException e)
+        {
+            assertSame(exception, e);
+        }
 
         verifyControls();
     }

Modified: jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/service/impl/TestObjectProviders.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/service/impl/TestObjectProviders.java?rev=190895&r1=190894&r2=190895&view=diff
==============================================================================
--- jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/service/impl/TestObjectProviders.java
(original)
+++ jakarta/hivemind/trunk/framework/src/test/org/apache/hivemind/service/impl/TestObjectProviders.java
Thu Jun 16 03:56:29 2005
@@ -53,7 +53,7 @@
         MockControl mc = newControl(Module.class);
         Module m = (Module) mc.getMock();
 
-        m.getService("fred", Location.class);
+        m.getService("fred", Object.class);
         mc.setReturnValue(expected);
 
         replayControls();



---------------------------------------------------------------------
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