summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/modules')
-rw-r--r--sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java11
-rw-r--r--sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java22
-rw-r--r--sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java16
-rw-r--r--sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java2
-rw-r--r--sca-java-2.x/trunk/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties7
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java7
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java15
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties3
-rw-r--r--sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java67
-rw-r--r--sca-java-2.x/trunk/modules/databinding/src/main/resources/org/apache/tuscany/sca/databinding/databinding-validation-messages.properties35
-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
-rw-r--r--sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java21
-rw-r--r--sca-java-2.x/trunk/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties1
-rw-r--r--sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java11
-rw-r--r--sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java6
16 files changed, 217 insertions, 57 deletions
diff --git a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
index 966c0ac275..d9fe434795 100644
--- a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
+++ b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
@@ -304,8 +304,13 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
property.setXSDType(getQName(reader, TYPE));
// MJE added 14/05/2009 - check for both @element and @type being present - disallowed by OASIS Assembly spec
if( property.getXSDElement() != null && property.getXSDType() != null ) {
- ContributionReadException ce = new ContributionReadException("[ASM40010,ASM60040] Error: property has both @type and @element attribute values - " +
- property.getName());
+ // TUSCANY-4020 - should get rid of the exception but that would mean getting OASIS to change the
+ // expected strings again
+ ContributionReadException ce = new ContributionReadException(context.getMonitor().getMessageString(BaseAssemblyProcessor.class.getName(),
+ Messages.RESOURCE_BUNDLE,
+ "BothTypeAndElementAttributeFound") +
+ " - " +
+ property.getName());
error(context.getMonitor(), "ContributionReadException", property, ce);
} // end if
@@ -512,7 +517,7 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
// A property <value/> subelement MUST NOT be used when the @value attribute is used
// to specify the value for that property.
if (valueAttr != null) {
- error(context.getMonitor(), "ASM50033: value attribute exists for the property element", name, name);
+ error(context.getMonitor(), "ValueAttributeForPropertyElement", element, nameAttr);
}
// Read <value>
if (VALUE_QNAME.equals(name)) {
diff --git a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
index 5ba42a0dec..47f61ffe23 100644
--- a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
+++ b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
@@ -73,14 +73,20 @@ public class CompositeDocumentProcessor extends BaseAssemblyProcessor implements
*/
public Composite read(URL contributionURL, URI uri, URL url, ProcessorContext context) throws ContributionReadException {
if( uri == null || url == null ) {
- throw new ContributionReadException("Request to read composite with uri or url NULL");
+ throw new ContributionReadException(context.getMonitor().getMessageString(CompositeDocumentProcessor.class.getName(),
+ Messages.RESOURCE_BUNDLE,
+ "NullURL"));
} // end if
InputStream scdlStream = null;
try {
scdlStream = IOHelper.openStream(url);
} catch (IOException e) {
- ContributionReadException ce = new ContributionReadException("Exception reading " + uri, e);
+ ContributionReadException ce = new ContributionReadException(context.getMonitor().getMessageString(CompositeDocumentProcessor.class.getName(),
+ Messages.RESOURCE_BUNDLE,
+ "ReadException") +
+ " " +
+ uri, e);
error(context.getMonitor(), "ContributionReadException", url, ce);
throw ce;
}
@@ -119,7 +125,11 @@ public class CompositeDocumentProcessor extends BaseAssemblyProcessor implements
return composite;
} catch (XMLStreamException e) {
- ContributionReadException ce = new ContributionReadException("Exception reading " + uri, e);
+ ContributionReadException ce = new ContributionReadException(context.getMonitor().getMessageString(CompositeDocumentProcessor.class.getName(),
+ Messages.RESOURCE_BUNDLE,
+ "ReadException") +
+ " " +
+ uri, e);
error(context.getMonitor(), "ContributionReadException", inputFactory, ce);
throw ce;
} finally {
@@ -169,7 +179,11 @@ public class CompositeDocumentProcessor extends BaseAssemblyProcessor implements
extensionProcessor.resolve(composite, resolver, context);
} catch (Throwable e ) {
// Add information about which composite was being processed when the exception occurred
- String newMessage = "Processing composite " + composite.getName() + ": " + e.getMessage();
+ String newMessage = context.getMonitor().getMessageString(CompositeDocumentProcessor.class.getName(),
+ Messages.RESOURCE_BUNDLE,
+ "ProcessingComposite") +
+ " " +
+ composite.getName() + ": " + e.getMessage();
throw new ContributionResolveException( newMessage, e );
} // end try
}
diff --git a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
index 55e4cc53ae..e32171a0ee 100644
--- a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
+++ b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
@@ -1040,15 +1040,19 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt
if ((composite.isLocal() && resolved.isLocal()) || (!composite.isLocal() && !resolved.isLocal())) {
composite.getIncludes().set(i, resolved);
} else {
- ContributionResolveException ce =
- new ContributionResolveException("[ASM60041] Error: Composite " + composite.getName()
- + " can only include another composite with the identical @local attribute value");
+ String message = context.getMonitor().getMessageString(CompositeProcessor.class.getName(),
+ Messages.RESOURCE_BUNDLE,
+ "LocalAttibuteMissmatch");
+ message = message.replace("{0}", composite.getName().toString());
+ ContributionResolveException ce = new ContributionResolveException(message);
error(monitor, "ContributionResolveException", include, ce);
}
} else {
- ContributionResolveException ce =
- new ContributionResolveException("[ASM60042] Error: Composite " + include.getName()
- + " is not a valid composite within the domain");
+ String message = context.getMonitor().getMessageString(CompositeProcessor.class.getName(),
+ Messages.RESOURCE_BUNDLE,
+ "CompositeNotFound");
+ message = message.replace("{0}", include.getName().toString());
+ ContributionResolveException ce = new ContributionResolveException(message);
error(monitor, "ContributionResolveException", include, ce);
}
}
diff --git a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
index 2498f3df67..fa56bf0503 100644
--- a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
+++ b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
@@ -73,6 +73,4 @@ public interface PolicyConstants {
QName POLICY_SET_REFERENCE_QNAME = new QName(SCA11_NS, POLICY_SET_REFERENCE);
QName INTENT_QUALIFIER_QNAME = new QName(SCA11_NS, INTENT_QUALIFIER);
QName EXTERNAL_ATTACHMENT_QNAME = new QName(SCA11_NS, EXTERNAL_ATTACHMENT);
- String QUALIFIED_INTENT_CONSTRAINS_ERROR = " - Qualified Intents must not specify 'constrains' attribute";
-
}
diff --git a/sca-java-2.x/trunk/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties b/sca-java-2.x/trunk/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties
index ba0137c85c..a50e7d347f 100644
--- a/sca-java-2.x/trunk/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties
+++ b/sca-java-2.x/trunk/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties
@@ -30,3 +30,10 @@ ContributionWriteException = ContributionWriteException occured due to : {0}
XMLStreamException = XMLStreamException occured due to : {0}
DuplicateCompositeName = [ASM_6001] More than one composite with the same name {0} found in contribution {1}
PropertyTypeNotFound = The type {0} specified on property {1} of {2} can''t be found in any loaded contribution (makes sure the .xsd file is in a contribution, that the contribution is being loaded and that contribution imports and exports are correct)
+BothTypeAndElementAttributeFound = [ASM40010,ASM60040] Error: property has both @type and @element attribute values
+ValueAttributeForPropertyElement = ASM50033: value attribute exists for the property element {0}
+NullURL = Request to read composite with uri or url NULL
+ReadException = Exception reading
+ProcessingComposite = Processing composite
+LocalAttibuteMissmatch = [ASM60041] Error: Composite {0} can only include another composite with the identical @local attribute value
+CompositeNotFound = [ASM60042] Error: Composite {0} is not a valid composite within the domain
diff --git a/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java b/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
index 302088082e..e296e8cee5 100644
--- a/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
+++ b/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
@@ -46,6 +46,7 @@ import org.apache.tuscany.sca.assembly.Callback;
import org.apache.tuscany.sca.assembly.Extensible;
import org.apache.tuscany.sca.assembly.Extension;
import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.xml.Messages;
import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
@@ -312,7 +313,11 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem
if (END_POINT_REFERENCE.equals(reader.getName().getLocalPart())) {
if (wsdlElement != null && (wsdlElementIsBinding == null || !wsdlElementIsBinding)) {
error(monitor, "MustUseWsdlBinding", reader, wsdlElement);
- throw new ContributionReadException(wsdlElement + " must use wsdl.binding when using wsa:EndpointReference");
+ String message = context.getMonitor().getMessageString(WebServiceBindingProcessor.class.getName(),
+ "binding-wsxml-validation-messages",
+ "MustUseWsdlBinding");
+ message = message.replace("{0}", wsdlElement);
+ throw new ContributionReadException(message);
}
wsBinding.setEndPointReference(EndPointReferenceHelper.readEndPointReference(reader));
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
index cd8115d201..536534b743 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
@@ -42,6 +42,7 @@ import org.apache.tuscany.sca.assembly.builder.BuilderContext;
import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.PolicyBuilder;
+import org.apache.tuscany.sca.assembly.xml.Messages;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
@@ -211,8 +212,8 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
"endpoint-validation-messages",
"NoComponentReferenceTarget",
endpointReference.getReference().getName());
- throw new ServiceRuntimeException("Unable to bind " +
- monitor.getLastProblem().toString());
+ //throw new ServiceRuntimeException("Unable to bind " +
+ // monitor.getLastProblem().toString());
}
}
@@ -295,7 +296,10 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
"endpoint-validation-messages",
"NoEndpointsFound",
endpointReference.toString());
- throw new ServiceRuntimeException("Unable to bind " +
+ throw new ServiceRuntimeException(monitor.getMessageString(EndpointReferenceBinderImpl.class.getName(),
+ "endpoint-validation-messages",
+ "UnableToBind") +
+ " " +
monitor.getLastProblem().toString());
}
}
@@ -318,7 +322,10 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
"EndpointReferenceCantBeMatched",
endpointReference.toString(),
matchAudit);
- throw new ServiceRuntimeException("Unable to bind " +
+ throw new ServiceRuntimeException(monitor.getMessageString(EndpointReferenceBinderImpl.class.getName(),
+ "endpoint-validation-messages",
+ "UnableToBind") +
+ " " +
monitor.getLastProblem().toString());
} else {
Monitor.warning(monitor,
diff --git a/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties b/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties
index f300010bd4..121baddf5c 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties
+++ b/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties
@@ -22,4 +22,5 @@ NoEndpointsFound = No endpoints found in the domain that match the reference {0}
EndpointReferenceCantBeMatched = Unable to match the endpoint reference {0} with the policy of the service to which it refers, matching process was {1}
# Single quote (we'll) needs to be escaped as we''ll
ComponentReferenceTargetNotFound = Component reference target not found at deployment time, it might be a remote service elsewhere in the SCA Domain so we''ll try and resolve it again at runtime: {0}
-TooManyTargetServices = [ASM60048] A component reference {0} with only the target component service name specified {1} matches more than one service \ No newline at end of file
+TooManyTargetServices = [ASM60048] A component reference {0} with only the target component service name specified {1} matches more than one service
+UnableToBind = Unable to bind \ No newline at end of file
diff --git a/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java
index 0664902feb..aeb63ce02f 100644
--- a/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java
+++ b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java
@@ -29,6 +29,7 @@ import java.text.Format;
import java.text.ParsePosition;
import java.util.Calendar;
import java.util.TimeZone;
+import java.util.logging.Logger;
import javax.xml.XMLConstants;
import javax.xml.datatype.DatatypeConfigurationException;
@@ -44,6 +45,8 @@ import javax.xml.namespace.QName;
* @tuscany.spi.extension.asclient
*/
public class XSDDataTypeConverter {
+ private static final Logger logger = Logger.getLogger(XSDDataTypeConverter.class.getName(),
+ "org.apache.tuscany.sca.databinding.databinding-validation-messages");
/**
*
* @tuscany.spi.extension.asclient
@@ -192,7 +195,7 @@ public class XSDDataTypeConverter {
obuf[wp] = (byte) (b2 << 6 & 0xc0 | b3 & 0x3f);
return 3;
default:
- throw new IllegalArgumentException("The character sequence is not base64 encoded.");
+ throw new IllegalArgumentException(logger.getResourceBundle().getString("NotBase64Encoded"));
}
}
@@ -338,7 +341,7 @@ public class XSDDataTypeConverter {
*/
public static byte[] decode(String pValue) {
if ((pValue.length() % 2) != 0) {
- throw new IllegalArgumentException("A HexBinary string must have even length.");
+ throw new IllegalArgumentException(logger.getResourceBundle().getString("HexBinaryUnevenLength"));
}
byte[] result = new byte[pValue.length() / 2];
int j = 0;
@@ -354,7 +357,7 @@ public class XSDDataTypeConverter {
} else if (c >= 'a' && c <= 'f') {
b = (byte) ((c - 'a' + 10) << 4);
} else {
- throw new IllegalArgumentException("Invalid hex digit: " + c);
+ throw new IllegalArgumentException(logger.getResourceBundle().getString("InvalidHexDigit") + " " + c);
}
if (d >= '0' && d <= '9') {
b += (byte) (d - '0');
@@ -363,7 +366,7 @@ public class XSDDataTypeConverter {
} else if (d >= 'a' && d <= 'f') {
b += (byte) (d - 'a' + 10);
} else {
- throw new IllegalArgumentException("Invalid hex digit: " + d);
+ throw new IllegalArgumentException(logger.getResourceBundle().getString("InvalidHexDigit") + " " + d);
}
result[j++] = b;
}
@@ -718,8 +721,10 @@ public class XSDDataTypeConverter {
ParsePosition pos = new ParsePosition(0);
Calendar cal = (Calendar) format.parseObject(value, pos);
if (cal == null) {
- throw new IllegalArgumentException("Failed to parse date " + value + " at:"
- + value.substring(pos.getErrorIndex()));
+ String message = logger.getResourceBundle().getString("BadDate");
+ message = message.replace("{0}", value);
+ message = message.replace("{1}", value.substring(pos.getErrorIndex()));
+ throw new IllegalArgumentException(message);
}
return cal;
}
@@ -729,8 +734,10 @@ public class XSDDataTypeConverter {
ParsePosition pos = new ParsePosition(0);
Calendar cal = (Calendar) format.parseObject(value, pos);
if (cal == null) {
- throw new IllegalArgumentException("Failed to parse dateTime " + value + " at:"
- + value.substring(pos.getErrorIndex()));
+ String message = logger.getResourceBundle().getString("BadDateTime");
+ message = message.replace("{0}", value);
+ message = message.replace("{1}", value.substring(pos.getErrorIndex()));
+ throw new IllegalArgumentException(message);
}
return cal;
}
@@ -799,18 +806,21 @@ public class XSDDataTypeConverter {
// Should not happen, indicates an error in the
// NamespaceContext
// implementation
- throw new IllegalArgumentException("The default prefix is not bound.");
+ throw new IllegalArgumentException(logger.getResourceBundle().getString("DefaultPrefixNotBound"));
}
break;
case 0:
- throw new IllegalArgumentException("Default prefix must be indicated by not using a colon: "
- + value);
+ throw new IllegalArgumentException(logger.getResourceBundle().getString("NoColonForPrefix") +
+ " " +
+ value);
default:
String prefix = value.substring(0, offset);
localName = value.substring(offset + 1);
uri = context.getNamespaceURI(prefix);
if (uri == null) {
- throw new IllegalArgumentException("The prefix " + prefix + " is not bound.");
+ String message = logger.getResourceBundle().getString("PrefixNotBound");
+ message = message.replace("{0}", prefix);
+ throw new IllegalArgumentException(message);
}
}
return new QName(uri, localName);
@@ -829,8 +839,10 @@ public class XSDDataTypeConverter {
ParsePosition pos = new ParsePosition(0);
Calendar cal = (Calendar) format.parseObject(value, pos);
if (cal == null) {
- throw new IllegalArgumentException("Failed to parse time " + value + " at:"
- + value.substring(pos.getErrorIndex()));
+ String message = logger.getResourceBundle().getString("BadTime");
+ message = message.replace("{0}", value);
+ message = message.replace("{1}", value.substring(pos.getErrorIndex()));
+ throw new IllegalArgumentException(message);
}
return cal;
}
@@ -838,12 +850,15 @@ public class XSDDataTypeConverter {
public long parseUnsignedInt(String value) {
long l = Long.parseLong(value);
if (l < 0) {
- throw new IllegalArgumentException("Failed to parse UnsignedInt " + value
- + ": result is negative");
+ String message = logger.getResourceBundle().getString("BadUnsignedIntNegative");
+ message = message.replace("{0}", value);
+ throw new IllegalArgumentException(message);
}
if (l > MAX_UNSIGNED_INT) {
- throw new IllegalArgumentException("Failed to parse UnsignedInt " + value
- + ": result exceeds maximum value " + MAX_UNSIGNED_INT);
+ String message = logger.getResourceBundle().getString("BadUnsignedIntMax");
+ message = message.replace("{0}", value);
+ message = message.replace("{1}", String.valueOf(MAX_UNSIGNED_INT));
+ throw new IllegalArgumentException(message);
}
return l;
}
@@ -851,12 +866,15 @@ public class XSDDataTypeConverter {
public int parseUnsignedShort(String value) {
int i = Integer.parseInt(value);
if (i < 0) {
- throw new IllegalArgumentException("Failed to parse UnsignedShort " + value
- + ": result is negative");
+ String message = logger.getResourceBundle().getString("BadUnsignedShortNegative");
+ message = message.replace("{0}", value);
+ throw new IllegalArgumentException(message);
}
if (i > MAX_UNSIGNED_SHORT) {
- throw new IllegalArgumentException("Failed to parse UnsignedShort " + value
- + ": result exceeds maximum value " + MAX_UNSIGNED_SHORT);
+ String message = logger.getResourceBundle().getString("BadUnsignedShortMax");
+ message = message.replace("{0}", value);
+ message = message.replace("{1}", String.valueOf(MAX_UNSIGNED_SHORT));
+ throw new IllegalArgumentException(message);
}
return i;
}
@@ -920,8 +938,9 @@ public class XSDDataTypeConverter {
public String printQName(QName value, NamespaceContext context) {
String prefix = context.getPrefix(value.getNamespaceURI());
if (prefix == null) {
- throw new IllegalArgumentException("The namespace URI " + value.getNamespaceURI()
- + " is not bound.");
+ String message = logger.getResourceBundle().getString("NamespaceNotBound");
+ message = message.replace("{0}", value.getNamespaceURI());
+ throw new IllegalArgumentException(message);
} else if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
return value.getLocalPart();
} else {
diff --git a/sca-java-2.x/trunk/modules/databinding/src/main/resources/org/apache/tuscany/sca/databinding/databinding-validation-messages.properties b/sca-java-2.x/trunk/modules/databinding/src/main/resources/org/apache/tuscany/sca/databinding/databinding-validation-messages.properties
new file mode 100644
index 0000000000..0697b8b346
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/databinding/src/main/resources/org/apache/tuscany/sca/databinding/databinding-validation-messages.properties
@@ -0,0 +1,35 @@
+#
+#
+# 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.
+#
+#
+NotBase64Encoded = The character sequence is not base64 encoded
+HexBinaryUnevenLength = A HexBinary string must have even length
+InvalidHexDigit = Invalid hex digit:
+BadDate = Failed to parse date {0} at {1}
+BadDateTime = Failed to parse dateTime {0} at {1}
+DefaultPrefixNotBound = The default prefix is not bound
+NoColonForPrefix = Default prefix must be indicated by not using a colon:
+PrefixNotBound = The prefix {0} is not bound.
+BadTime = Failed to parse time {0} at {1}
+BadUnsignedIntNegative = Failed to parse UnsignedInt {0} result is negative"
+BadUnsignedIntMax = "Failed to parse UnsignedInt {0} result exceeds maximum value {1}
+BadUnsignedShortNegative = Failed to parse UnsignedShort {0} result is negative"
+BadUnsignedShortMax = "Failed to parse UnsignedShort {0} result exceeds maximum value {1}
+NamespaceNotBound = The namespace URI {0} is not bound
+
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}
+
+
diff --git a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java
index b321b0d5de..ed5fe421e2 100644
--- a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java
+++ b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java
@@ -33,6 +33,7 @@ import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.ws.WebServiceClient;
+import org.apache.tuscany.sca.assembly.xml.Messages;
import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
@@ -233,13 +234,18 @@ public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfa
javaInterface.setContributionContainingClass(classReference.getContributionContainingClass());
} catch (InvalidInterfaceException e) {
- ContributionResolveException ce = new ContributionResolveException("Resolving Java interface " + javaInterface.getName(), e);
- //error("ContributionResolveException", javaFactory, ce);
+ ContributionResolveException ce = new ContributionResolveException(context.getMonitor().getMessageString(JavaInterfaceProcessor.class.getName(),
+ "interface-javaxml-validation-messages",
+ "ResolvingInterface") +
+ javaInterface.getName(), e);
error(monitor, "InvalidInterfaceException", javaFactory, e);
return javaInterface;
- //throw ce;
} catch ( Exception e ) {
- throw new ContributionResolveException( "Resolving Java interface " + javaInterface.getName(), e );
+ throw new ContributionResolveException(context.getMonitor().getMessageString(JavaInterfaceProcessor.class.getName(),
+ "interface-javaxml-validation-messages",
+ "ResolvingInterface") +
+ " " +
+ javaInterface.getName(), e );
} // end try
// Cache the resolved interface
@@ -268,8 +274,11 @@ public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfa
checkForbiddenAnnotations(monitor, javaInterfaceContract);
} catch (Exception e) {
- throw new ContributionResolveException("Resolving Java Interface " + javaInterfaceContract.getInterface()
- .toString(), e);
+ throw new ContributionResolveException(context.getMonitor().getMessageString(JavaInterfaceProcessor.class.getName(),
+ "interface-javaxml-validation-messages",
+ "ResolvingInterface") +
+ " " +
+ javaInterfaceContract.getInterface().toString(), e);
} // end try
}
diff --git a/sca-java-2.x/trunk/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties b/sca-java-2.x/trunk/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties
index 329f55e0a7..c82d3876e9 100644
--- a/sca-java-2.x/trunk/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties
+++ b/sca-java-2.x/trunk/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties
@@ -25,4 +25,5 @@ ForbiddenAnnotationJCA30006 = [JCA30006] Forbidden annotation {0} found on servi
ForbiddenAnnotationJCA30007 = [JCA30007] Forbidden annotation {0} found on callback interface in class {1}
ForbiddenAnnotationJCA30008 = [JCA30008] Forbidden annotation {0} found in class {1}
ForbiddenAnnotationJCA100018 = [JCA100018] Forbidden annotation {0} found in class {1}
+ResolvingInterface = Resolving Java interface
diff --git a/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java b/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java
index eca0b9aba1..91f6bc9a9f 100644
--- a/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java
+++ b/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java
@@ -375,4 +375,15 @@ public abstract class Monitor {
return errorDetected;
}
+
+ /**
+ * Helper method to retrieve a localized message from a given bundle with a given
+ * message ID string
+ *
+ * @Param loggerName - the name of the logger to use
+ * @param messageBundleName - the name of the bundle to use
+ * @param messageID - the ID of the message to retrieve
+ * @return the message string
+ */
+ public abstract String getMessageString(String loggerName, String messageBundleName, String messageID);
}
diff --git a/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java b/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java
index c81581aae0..eb022a9616 100644
--- a/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java
+++ b/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java
@@ -141,4 +141,10 @@ public class MonitorImpl extends Monitor {
problemCache.clear();
artifactName = null;
}
+
+ @Override
+ public String getMessageString(String loggerName, String messageBundleName, String messageID){
+ Logger problemLogger = Logger.getLogger(loggerName, messageBundleName);
+ return problemLogger.getResourceBundle().getString(messageID);
+ }
}