summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/implementation-java-runtime/src
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2012-02-29 15:06:57 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2012-02-29 15:06:57 +0000
commit17e573358db8a4a83247037b957db32127bdd00a (patch)
tree6f5fdc4e5169f822571dd7b02e3a023d16a351c1 /sca-java-2.x/trunk/modules/implementation-java-runtime/src
parenta0a8ac0a56f74f88e0ffbc54aa45a85dbb14c419 (diff)
TUSCANY-4020 - move hardcoded message strings into properties files
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1295144 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-java-runtime/src')
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java24
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/resources/org/apache/tuscany/sca/implementation/java/runtime/implementation-java-runtime-validation-messages.properties26
2 files changed, 44 insertions, 6 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
index f5d9860130..967820abe7 100644
--- a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
+++ b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
@@ -20,10 +20,12 @@ package org.apache.tuscany.sca.implementation.java.context;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.util.logging.Logger;
import org.apache.tuscany.sca.core.factory.InstanceWrapper;
import org.apache.tuscany.sca.core.factory.ObjectCreationException;
import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.databinding.impl.XSDDataTypeConverter;
import org.apache.tuscany.sca.implementation.java.injection.Injector;
import org.apache.tuscany.sca.implementation.java.invocation.EventInvoker;
@@ -31,6 +33,9 @@ import org.apache.tuscany.sca.implementation.java.invocation.EventInvoker;
* @version $Rev$ $Date$
*/
public class ReflectiveInstanceFactory<T> implements InstanceFactory<T> {
+ private static final Logger logger = Logger.getLogger(ReflectiveInstanceFactory.class.getName(),
+ "org.apache.tuscany.sca.implementation.java.runtime.implementation-java-runtime-validation-messages");
+
private final Constructor<T> ctr;
private final ObjectFactory<?>[] ctrArgs;
private final Injector<T>[] injectors;
@@ -66,14 +71,19 @@ public class ReflectiveInstanceFactory<T> implements InstanceFactory<T> {
}
} catch (InstantiationException e) {
String name = ctr.getDeclaringClass().getName();
- throw new AssertionError("Class is not instantiable [" + name + "]");
+ String message = logger.getResourceBundle().getString("ClassNoInstantiable");
+ message = message.replace("{0}", name);
+ throw new AssertionError(message);
} catch (IllegalAccessException e) {
String name = ctr.getName();
- throw new AssertionError("Constructor is not accessible [" + name + "]");
- } catch (
- InvocationTargetException e) {
+ String message = logger.getResourceBundle().getString("ConstructorNotAccessible");
+ message = message.replace("{0}", name);
+ throw new AssertionError(message);
+ } catch (InvocationTargetException e) {
String name = ctr.getName();
- throw new ObjectCreationException("Exception thrown by constructor: " + name, e);
+ String message = logger.getResourceBundle().getString("ConstructorException");
+ message = message.replace("{0}", name);
+ throw new ObjectCreationException(message, e);
}
if (injectors != null) {
@@ -86,7 +96,9 @@ public class ReflectiveInstanceFactory<T> implements InstanceFactory<T> {
if (destroyInvoker != null) {
destroyInvoker.invokeEvent(instance);
}
- throw new ObjectCreationException("Exception invoking injector - " + e.getMessage(), e);
+ String message = logger.getResourceBundle().getString("InjectorException");
+ message = message.replace("{0}", e.getMessage());
+ throw new ObjectCreationException(message, e);
}
}
}
diff --git a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/resources/org/apache/tuscany/sca/implementation/java/runtime/implementation-java-runtime-validation-messages.properties b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/resources/org/apache/tuscany/sca/implementation/java/runtime/implementation-java-runtime-validation-messages.properties
new file mode 100644
index 0000000000..e7604d0858
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/resources/org/apache/tuscany/sca/implementation/java/runtime/implementation-java-runtime-validation-messages.properties
@@ -0,0 +1,26 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+#
+#
+ClassNoInstantiable = Class is not instantiable [{0}]
+ConstructorNotAccessible = Constructor is not accessible [{0}]
+ConstructorException = Exception thrown by constructor: {0}
+InjectorException = Exception invoking injector: {0}
+
+