summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-06-29 14:30:57 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-06-29 14:30:57 +0000
commitaa9506ef7f85f31995c35f400a473a2ffa7a8f82 (patch)
treedf17a5b391712d60fb237b61fd1297a2f81edab9
parent5d7e5e2989812810f377027952fd15861b278e20 (diff)
TUSCANY-3068 - Improve validation in JMS processors. Thanks for the patch Kaushik
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@789343 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java19
-rw-r--r--branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/OperationSelectorJMSUserPropProcessor.java8
-rw-r--r--branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultProcessor.java5
-rw-r--r--branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectProcessor.java5
4 files changed, 33 insertions, 4 deletions
diff --git a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
index 2ed1dcf48b..299d844b16 100644
--- a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
+++ b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
@@ -298,9 +298,18 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St
Object extension = extensionProcessor.read(reader);
if (extension != null) {
if (extension instanceof WireFormat) {
- jmsBinding.setRequestWireFormat((WireFormat)extension);
+ if (jmsBinding.getRequestWireFormat() == null) {
+ jmsBinding.setRequestWireFormat((WireFormat) extension);
+ } else {
+ throw new ContributionReadException("The request wireformat has already been defined. " + "Only one request wire format can be specified.");
+ }
} else if (extension instanceof OperationSelector) {
- jmsBinding.setOperationSelector((OperationSelector)extension);
+ if (jmsBinding.getOperationSelector() == null) {
+ jmsBinding.setOperationSelector((OperationSelector) extension);
+ } else {
+ throw new ContributionReadException("More than one operation selector has been specified. " + "Only one operation selector can be specified.");
+ }
+
} else {
error("UnexpectedElement", reader, extension.toString());
}
@@ -497,7 +506,11 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St
Object extension = extensionProcessor.read(reader);
if (extension != null) {
if (extension instanceof WireFormat) {
- jmsBinding.setResponseWireFormat((WireFormat)extension);
+ if (jmsBinding.getResponseWireFormat() == null) {
+ jmsBinding.setResponseWireFormat((WireFormat)extension);
+ } else {
+ throw new ContributionReadException("The response wireformat has already been defined. " + "Only one response wire format can be specified.");
+ }
} else {
error("UnexpectedElement", reader, extension.toString());
}
diff --git a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/OperationSelectorJMSUserPropProcessor.java b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/OperationSelectorJMSUserPropProcessor.java
index ef7912cf62..f1fd97cb4e 100644
--- a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/OperationSelectorJMSUserPropProcessor.java
+++ b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/OperationSelectorJMSUserPropProcessor.java
@@ -51,7 +51,13 @@ public class OperationSelectorJMSUserPropProcessor extends BaseStAXArtifactProce
public OperationSelectorJMSUserProp read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
OperationSelectorJMSUserProp opSelector = new OperationSelectorJMSUserProp();
String propertyName = reader.getAttributeValue(null, OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_ATTR);
- opSelector.setPropertyName(propertyName);
+ if (propertyName != null && propertyName.length() > 0) {
+ opSelector.setPropertyName(propertyName);
+ } else {
+ throw new ContributionReadException(OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_QNAME.toString() + ": " +
+ OperationSelectorJMSUserProp.OPERATION_SELECTOR_JMS_USERPROP_ATTR + " is a required attribute.");
+ }
+
return opSelector;
}
diff --git a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultProcessor.java b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultProcessor.java
index 73c4876025..1c3f666577 100644
--- a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultProcessor.java
+++ b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultProcessor.java
@@ -57,6 +57,11 @@ public class WireFormatJMSDefaultProcessor extends BaseStAXArtifactProcessor imp
if (sendFormat != null && sendFormat.length() > 0) {
if (WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_TEXT_FORMAT_VAL.equalsIgnoreCase(sendFormat)) {
wireFormat.setUseBytesMessage(false);
+ }else if (WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_BYTES_FORMAT_VAL.equalsIgnoreCase(sendFormat)) {
+ wireFormat.setUseBytesMessage(true);
+ }else{
+ throw new ContributionReadException(WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_QNAME.toString() +" " +sendFormat + " is not a valid attribute value for " +
+ WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_FORMAT_ATTR);
}
}
diff --git a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectProcessor.java b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectProcessor.java
index d38701d29b..62b2a91d62 100644
--- a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectProcessor.java
+++ b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectProcessor.java
@@ -57,6 +57,11 @@ public class WireFormatJMSObjectProcessor extends BaseStAXArtifactProcessor impl
if (wrappedSingleInput != null && wrappedSingleInput.length() > 0) {
if ("true".equalsIgnoreCase(wrappedSingleInput)) {
wireFormat.setWrappedSingleInput(true);
+ } else if ("false".equalsIgnoreCase(wrappedSingleInput)) {
+ wireFormat.setWrappedSingleInput(false);
+ } else {
+ throw new ContributionReadException(WireFormatJMSObject.WIRE_FORMAT_JMS_BYTES_QNAME.toString() + ": " + wrappedSingleInput +
+ " is not a valid attribute value for " + WireFormatJMSObject.WIRE_FORMAT_JMS_OBJECT_WRAP_SINGLE_ATTR);
}
}
return wireFormat;