From 17e573358db8a4a83247037b957db32127bdd00a Mon Sep 17 00:00:00 2001 From: slaws Date: Wed, 29 Feb 2012 15:06:57 +0000 Subject: 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 --- .../java/context/ReflectiveInstanceFactory.java | 24 +++++++++++++++----- ...ion-java-runtime-validation-messages.properties | 26 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 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 (limited to 'sca-java-2.x/trunk/modules/implementation-java-runtime/src') 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 implements InstanceFactory { + 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 ctr; private final ObjectFactory[] ctrArgs; private final Injector[] injectors; @@ -66,14 +71,19 @@ public class ReflectiveInstanceFactory implements InstanceFactory { } } 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 implements InstanceFactory { 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} + + -- cgit v1.2.3