Index: .classpath
===================================================================
RCS file: /home/cvspublic/jakarta-hivemind/.classpath,v
retrieving revision 1.38
diff -u -r1.38 .classpath
--- .classpath 1 Sep 2004 11:31:51 -0000 1.38
+++ .classpath 4 Sep 2004 21:30:28 -0000
@@ -1,31 +1,28 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: .project
===================================================================
RCS file: /home/cvspublic/jakarta-hivemind/.project,v
retrieving revision 1.3
diff -u -r1.3 .project
--- .project 19 Aug 2004 22:24:01 -0000 1.3
+++ .project 4 Sep 2004 21:30:28 -0000
@@ -10,6 +10,29 @@
+
+ org.eclipse.ui.externaltools.ExternalToolBuilder
+
+
+ LaunchConfigHandle
+ <project>/.externalToolBuilders/com.ibm.sse.model.structuredbuilder.launch
+
+
+
+
+ org.eclipse.ui.externaltools.ExternalToolBuilder
+
+
+ LaunchConfigHandle
+ <project>/.externalToolBuilders/Ant Build.launch
+
+
+
+
+ com.ibm.sse.model.structuredbuilder
+
+
+
org.eclipse.jdt.core.javanature
Index: framework/build.xml
===================================================================
RCS file: /home/cvspublic/jakarta-hivemind/framework/build.xml,v
retrieving revision 1.13
diff -u -r1.13 build.xml
--- framework/build.xml 18 Aug 2004 22:48:23 -0000 1.13
+++ framework/build.xml 4 Sep 2004 21:30:28 -0000
@@ -27,6 +27,7 @@
+
Index: framework/src/java/org/apache/hivemind/schema/rules/RulesMessages.java
===================================================================
RCS file: /home/cvspublic/jakarta-hivemind/framework/src/java/org/apache/hivemind/schema/rules/RulesMessages.java,v
retrieving revision 1.6
diff -u -r1.6 RulesMessages.java
--- framework/src/java/org/apache/hivemind/schema/rules/RulesMessages.java 1 Aug 2004 17:40:36 -0000 1.6
+++ framework/src/java/org/apache/hivemind/schema/rules/RulesMessages.java 4 Sep 2004 21:30:28 -0000
@@ -167,6 +167,11 @@
return _formatter.format("no-property-editor", propertyType.getName());
}
+ public static String noConverter( Class propertyType )
+ {
+ return _formatter.format( "no-converter", propertyType.getName() );
+ }
+
public static String smartTranslatorError(
String inputValue,
Class propertyType,
Index: framework/src/java/org/apache/hivemind/schema/rules/RulesStrings.properties
===================================================================
RCS file: /home/cvspublic/jakarta-hivemind/framework/src/java/org/apache/hivemind/schema/rules/RulesStrings.properties,v
retrieving revision 1.3
diff -u -r1.3 RulesStrings.properties
--- framework/src/java/org/apache/hivemind/schema/rules/RulesStrings.properties 1 Aug 2004 17:40:36 -0000 1.3
+++ framework/src/java/org/apache/hivemind/schema/rules/RulesStrings.properties 4 Sep 2004 21:30:29 -0000
@@ -41,5 +41,5 @@
invalid-initializer=Initializer string (''{0}'') is not in proper format (key=value[,key=value]*).
no-property-editor=No property editor for {0}.
smart-translator-error=Unable to translate ''{0}'' to type {1}: {2}
-
+no-converter=There is no converter registered for type {0}.
unable-to-instantiate-instance-of-class=Unable to instantiate instance of class {0}: {1}
Index: framework/src/java/org/apache/hivemind/schema/rules/SmartTranslator.java
===================================================================
RCS file: /home/cvspublic/jakarta-hivemind/framework/src/java/org/apache/hivemind/schema/rules/SmartTranslator.java,v
retrieving revision 1.5
diff -u -r1.5 SmartTranslator.java
--- framework/src/java/org/apache/hivemind/schema/rules/SmartTranslator.java 10 Aug 2004 13:18:50 -0000 1.5
+++ framework/src/java/org/apache/hivemind/schema/rules/SmartTranslator.java 4 Sep 2004 21:30:29 -0000
@@ -14,10 +14,10 @@
package org.apache.hivemind.schema.rules;
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
import java.util.Map;
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.Converter;
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.Location;
import org.apache.hivemind.internal.Module;
@@ -26,7 +26,7 @@
/**
* A "smart" translator that attempts to automatically convert from string types
* to object or wrapper types, using {@link java.beans.PropertyEditor}s.
- *
+ *
* @author Howard Lewis Ship
*/
public class SmartTranslator implements Translator
@@ -50,11 +50,8 @@
_default = (String) m.get("default");
}
- public Object translate(
- Module contributingModule,
- Class propertyType,
- String inputValue,
- Location location)
+ public Object translate(Module contributingModule, Class propertyType,
+ String inputValue, Location location)
{
if (inputValue == null)
{
@@ -64,28 +61,15 @@
inputValue = _default;
}
- try
+ final Converter converter = ConvertUtils.lookup(propertyType);
+ if (converter == null)
{
- PropertyEditor e = PropertyEditorManager.findEditor(propertyType);
-
- if (e == null)
- throw new ApplicationRuntimeException(
- RulesMessages.noPropertyEditor(propertyType),
- location,
- null);
-
- e.setAsText(inputValue);
-
- return e.getValue();
- }
- catch (Exception ex)
+ throw new ApplicationRuntimeException(RulesMessages.noConverter(propertyType), location, null);
+ } else
{
- throw new ApplicationRuntimeException(
- RulesMessages.smartTranslatorError(inputValue, propertyType, ex),
- location,
- ex);
-
+ return converter.convert(propertyType, inputValue);
}
+
}
-}
+}
\ No newline at end of file
Index: framework/src/test/hivemind/test/rules/TestSmartTranslator.java
===================================================================
RCS file: /home/cvspublic/jakarta-hivemind/framework/src/test/hivemind/test/rules/TestSmartTranslator.java,v
retrieving revision 1.5
diff -u -r1.5 TestSmartTranslator.java
--- framework/src/test/hivemind/test/rules/TestSmartTranslator.java 10 Aug 2004 13:18:50 -0000 1.5
+++ framework/src/test/hivemind/test/rules/TestSmartTranslator.java 4 Sep 2004 21:30:29 -0000
@@ -21,9 +21,11 @@
import org.apache.hivemind.schema.rules.SmartTranslator;
import org.apache.hivemind.test.HiveMindTestCase;
+import sun.util.logging.resources.logging;
+
/**
* Tests for {@link org.apache.hivemind.schema.rules.SmartTranslator}.
- *
+ *
* @author Howard Lewis Ship
*/
public class TestSmartTranslator extends HiveMindTestCase
@@ -76,20 +78,19 @@
}
/**
- * Test with a String value (apparently, this doesn't always work,
- * see bug HIVEMIND-15).
+ * Test with a String value (apparently, this doesn't always work, see bug
+ * HIVEMIND-15).
*/
public void testString()
{
Translator t = new SmartTranslator();
-
- Object result = t.translate(null, String.class, "Fluffy Puppies", null);
-
- assertEquals("Fluffy Puppies", result);
+ final String value = "Fluffy Puppies";
+ Object result = t.translate(null, String.class, value, null);
+ assertEquals(value, result);
}
- public void testNoEditor()
+ public void testNoConverter()
{
Translator t = new SmartTranslator();
Location l = fabricateLocation(22);
@@ -97,17 +98,12 @@
try
{
t.translate(null, Registry.class, "fred", l);
-
unreachable();
- }
- catch (ApplicationRuntimeException ex)
+ } catch (ApplicationRuntimeException ex)
{
- assertEquals(
- "Unable to translate 'fred' to type org.apache.hivemind.Registry: "
- + "No property editor for org.apache.hivemind.Registry.",
- ex.getMessage());
-
+ assertEquals("There is no converter registered for type "
+ + Registry.class.getName() + ".", ex.getMessage());
assertSame(l, ex.getLocation());
}
}
-}
+}
\ No newline at end of file
Index: library/build.xml
===================================================================
RCS file: /home/cvspublic/jakarta-hivemind/library/build.xml,v
retrieving revision 1.11
diff -u -r1.11 build.xml
--- library/build.xml 10 Aug 2004 14:25:11 -0000 1.11
+++ library/build.xml 4 Sep 2004 21:30:29 -0000
@@ -37,6 +37,7 @@
+
Index: .externalToolBuilders/Ant Build.launch
===================================================================
RCS file: .externalToolBuilders/Ant Build.launch
diff -N .externalToolBuilders/Ant Build.launch
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ .externalToolBuilders/Ant Build.launch 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: .externalToolBuilders/com.ibm.sse.model.structuredbuilder.launch
===================================================================
RCS file: .externalToolBuilders/com.ibm.sse.model.structuredbuilder.launch
diff -N .externalToolBuilders/com.ibm.sse.model.structuredbuilder.launch
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ .externalToolBuilders/com.ibm.sse.model.structuredbuilder.launch 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,6 @@
+
+
+
+
+
+
Index: library/src/java/org/apache/hivemind/lib/impl/RmiServiceImplementationFactory.java
===================================================================
RCS file: library/src/java/org/apache/hivemind/lib/impl/RmiServiceImplementationFactory.java
diff -N library/src/java/org/apache/hivemind/lib/impl/RmiServiceImplementationFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ library/src/java/org/apache/hivemind/lib/impl/RmiServiceImplementationFactory.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,101 @@
+//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.impl;
+
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.hivemind.ServiceImplementationFactory;
+import org.apache.hivemind.internal.Module;
+
+/**
+ * An implementation of {@link org.apache.hivemind.ServiceImplementationFactory}
+ * that looks up a service implementation object in an RMI registry.
+ *
+ * @author James Carman
+ */
+public class RmiServiceImplementationFactory implements ServiceImplementationFactory
+{
+ private String host;
+
+ private int port = Registry.REGISTRY_PORT;
+
+ private String name;
+
+ public Object createCoreServiceImplementation(String serviceId,
+ Class serviceInterface, Log serviceLog, Module invokingModule,
+ List parameters)
+ {
+ try {
+ final Registry registry = LocateRegistry.getRegistry(host, port);
+ return registry.lookup(name);
+ } catch (RemoteException e) {
+ throw new ApplicationRuntimeException( "Unable to lookup RMI service object.", e );
+ } catch (NotBoundException e) {
+ throw new ApplicationRuntimeException( "The name '" + name + "' was not bound in the RMI registry located at " + host + ":" + port + ".", e );
+ }
+
+ }
+
+ /**
+ * @return Returns the host.
+ */
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * @param host
+ * The host to set.
+ */
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name
+ * The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return Returns the port.
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * @param port
+ * The port to set.
+ */
+ public void setPort(int port) {
+ this.port = port;
+ }
+}