Author: slaws
Date: Wed Feb 29 15:06:57 2012
New Revision: 1295144
URL: http://svn.apache.org/viewvc?rev=1295144&view=rev
Log:
TUSCANY-4020 - move hardcoded message strings into properties files
Added:
tuscany/sca-java-2.x/trunk/modules/databinding/src/main/resources/org/
tuscany/sca-java-2.x/trunk/modules/databinding/src/main/resources/org/apache/
tuscany/sca-java-2.x/trunk/modules/databinding/src/main/resources/org/apache/tuscany/
tuscany/sca-java-2.x/trunk/modules/databinding/src/main/resources/org/apache/tuscany/sca/
tuscany/sca-java-2.x/trunk/modules/databinding/src/main/resources/org/apache/tuscany/sca/databinding/
tuscany/sca-java-2.x/trunk/modules/databinding/src/main/resources/org/apache/tuscany/sca/databinding/databinding-validation-messages.properties
tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/resources/org/apache/tuscany/sca/implementation/java/runtime/
tuscany/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
Modified:
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
tuscany/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties
tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java
tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java
tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties
tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java
tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java
Modified:
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
Wed Feb 29 15:06:57 2012
@@ -304,8 +304,13 @@ abstract class BaseAssemblyProcessor ext
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 ext
// 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)) {
Modified:
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
Wed Feb 29 15:06:57 2012
@@ -73,14 +73,20 @@ public class CompositeDocumentProcessor
*/
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
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
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
}
Modified:
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
Wed Feb 29 15:06:57 2012
@@ -1040,15 +1040,19 @@ public class CompositeProcessor extends
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);
}
}
Modified:
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
Wed Feb 29 15:06:57 2012
@@ -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";
-
}
Modified:
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties
(original)
+++
tuscany/sca-java-2.x/trunk/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties
Wed Feb 29 15:06:57 2012
@@ -30,3 +30,10 @@ ContributionWriteException = Contributio
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
Modified:
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
Wed Feb 29 15:06:57 2012
@@ -46,6 +46,7 @@ import org.apache.tuscany.sca.assembly.C
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
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));
Modified:
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
Wed Feb 29 15:06:57 2012
@@ -42,6 +42,7 @@ import org.apache.tuscany.sca.assembly.b
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
"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
"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
"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,
Modified:
tuscany/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties
(original)
+++
tuscany/sca-java-2.x/trunk/modules/core/src/main/resources/endpoint-validation-messages.properties
Wed Feb 29 15:06:57 2012
@@ -22,4 +22,5 @@ NoEndpointsFound = No endpoints found in
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
Modified:
tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java
Wed Feb 29 15:06:57 2012
@@ -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 {
Added:
tuscany/sca-java-2.x/trunk/modules/databinding/src/main/resources/org/apache/tuscany/sca/databinding/databinding-validation-messages.properties
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/databinding/src/main/resources/org/apache/tuscany/sca/databinding/databinding-validation-messages.properties?rev=1295144&view=auto
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/databinding/src/main/resources/org/apache/tuscany/sca/databinding/databinding-validation-messages.properties
(added)
+++
tuscany/sca-java-2.x/trunk/modules/databinding/src/main/resources/org/apache/tuscany/sca/databinding/databinding-validation-messages.properties
Wed Feb 29 15:06:57 2012
@@ -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
+
Modified:
tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
Wed Feb 29 15:06:57 2012
@@ -20,10 +20,12 @@ package org.apache.tuscany.sca.implement
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.implementa
* @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
}
} 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
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);
}
}
}
Added:
tuscany/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
URL:
http://svn.apache.org/viewvc/tuscany/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?rev=1295144&view=auto
==============================================================================
---
tuscany/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
(added)
+++
tuscany/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
Wed Feb 29 15:06:57 2012
@@ -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}
+
+
Modified:
tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java
Wed Feb 29 15:06:57 2012
@@ -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 impl
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 impl
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
}
Modified:
tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties
(original)
+++
tuscany/sca-java-2.x/trunk/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties
Wed Feb 29 15:06:57 2012
@@ -25,4 +25,5 @@ ForbiddenAnnotationJCA30006 = [JCA30006]
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
Modified:
tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java
Wed Feb 29 15:06:57 2012
@@ -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);
}
Modified:
tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java?rev=1295144&r1=1295143&r2=1295144&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java
Wed Feb 29 15:06:57 2012
@@ -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);
+ }
}