summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-jms
diff options
context:
space:
mode:
authorbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-09-08 00:18:50 +0000
committerbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-09-08 00:18:50 +0000
commit1315e46609bf6beb0c275c59176c846c17b3c614 (patch)
treeb1366a4d3eca86b7d384459953a6cd9774d18688 /sca-java-2.x/trunk/modules/binding-jms
parent27e3cec43d8effa06ba8710907e416539b332096 (diff)
TUSCANY-3673 Update JMS binding model to separate out type/priority/deliveryMode/timeToLive attributes originating from the uri, operation prop headers, and headers. Also use that information in the runtime to correctly determine the value that is used when more than one is specified.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@993564 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-jms')
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java172
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java39
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java8
3 files changed, 155 insertions, 64 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java b/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java
index 977ef17d52..fcd022dfea 100644
--- a/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java
+++ b/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java
@@ -122,11 +122,7 @@ public class JMSBinding implements Binding, PolicySubject, OperationsConfigurato
private boolean containsHeaders = false;
private String replyTo;
- private String jmsType;
private String jmsCorrelationId;
- private Boolean deliveryModePersistent;
- private Long timeToLive;
- private Integer jmsPriority;
private Map<String, Object> properties = new HashMap<String, Object>();
private Map<String, Map<String, Object>> operationProperties = new HashMap<String, Map<String,Object>>();
@@ -151,6 +147,20 @@ public class JMSBinding implements Binding, PolicySubject, OperationsConfigurato
private OperationSelector operationSelector;
private ExtensionType extensionType;
private String jmsURI;
+
+ private String uriType;
+ private Boolean uriDeliveryMode;
+ private Integer uriJMSPriority;
+ private Long uriJMSTimeToLive;
+
+ private String headerType;
+ private Boolean headerDeliveryMode;
+ private Integer headerPriority;
+ private Long headerTimeToLive;
+
+ private final Integer defaultPriority = Integer.valueOf(4);
+ private final Boolean defaultDeliveryMode = true;
+ private final Long defaultJMSTimeToLive =Long.valueOf(0);
public JMSBinding() {
super();
@@ -468,47 +478,81 @@ public class JMSBinding implements Binding, PolicySubject, OperationsConfigurato
this.replyTo = replyTo;
}
- public String getJMSType() {
- return jmsType;
+ // getEffective...() will return values based on the following priority
+ // 1. The value specified in the URI attribute
+ // 2. The value specified in the operationProperties/headers
+ // 3. The value specified in the headers element
+ // 4. The default value from the headers element
+ public String getEffectiveJMSType(String opName) {
+ if ( getJMSURIType() != null ) return getJMSURIType();
+ else if ( getOperationJMSType(opName) != null ) return getOperationJMSType(opName);
+ else if ( getJMSHeaderType() != null ) return getJMSHeaderType();
+ else return null;
}
- public void setJMSType(String jmsType) {
- setHeaders( true );
- this.jmsType = jmsType;
- }
-
- public String getJMSCorrelationId() {
- return jmsCorrelationId;
+
+ public Boolean getEffectiveJMSDeliveryMode(String opName) {
+ if ( getURIJMSDeliveryMode() != null ) return getURIJMSDeliveryMode();
+ else if ( getOperationJMSDeliveryMode(opName) != null) return getOperationJMSDeliveryMode(opName);
+ else if ( getHeaderJMSDeliveryMode() != null) return getHeaderJMSDeliveryMode();
+ else return getDefaultDeliveryMode();
}
- public void setJMSCorrelationId(String jmsCorrelationId) {
- setHeaders( true );
- this.jmsCorrelationId = jmsCorrelationId;
+ public Long getEffectiveJMSTimeToLive(String opName) {
+ if ( getURIJMSTimeToLive() != null ) return getURIJMSTimeToLive();
+ else if ( getOperationJMSTimeToLive(opName) != null) return getOperationJMSTimeToLive(opName);
+ else if ( getHeaderJMSTimeToLive() != null) return getHeaderJMSTimeToLive();
+ else return getDefaultJMSTimeToLive();
}
- public Boolean isdeliveryModePersistent() {
- return deliveryModePersistent;
- }
- public void setJMSDeliveryMode(boolean persistent) {
- setHeaders( true );
- this.deliveryModePersistent = Boolean.valueOf(persistent);
+ public Integer getEffectiveJMSPriority(String operationName) {
+ if ( getURIJMSPriority() != null ) return getURIJMSPriority();
+ else if ( getOperationJMSPriority(operationName)!= null) return getOperationJMSPriority(operationName);
+ else if ( getJMSHeaderPriority() != null ) return getJMSHeaderPriority();
+ else return getDefaultJMSPriority();
}
- public Integer getJMSPriority() {
- return jmsPriority;
- }
- public void setJMSPriority(int jmsPriority) {
- setHeaders( true );
- this.jmsPriority = Integer.valueOf(jmsPriority);
- }
+ private Long getHeaderJMSTimeToLive() {
+ return this.headerTimeToLive;
+ }
- public Long getJMSTimeToLive() {
- return timeToLive;
- }
+ private Long getDefaultJMSTimeToLive() {
+ return this.defaultJMSTimeToLive;
+ }
- public void setJMSTimeToLive(long timeToLive) {
+ private Boolean getDefaultDeliveryMode() {
+ return this.defaultDeliveryMode;
+ }
+
+ private Boolean getHeaderJMSDeliveryMode() {
+ return headerDeliveryMode;
+ }
+
+ private Boolean getURIJMSDeliveryMode() {
+ return this.uriDeliveryMode;
+ }
+
+ public String getJMSURIType() {
+ return uriType;
+ }
+ public void setJMSURIType(String type) {
+ this.uriType = type;
+ }
+ public String getJMSHeaderType() {
+ return headerType;
+ }
+
+ public void setJMSHeaderType(String type) {
+ this.headerType = type;
+ }
+
+ public String getJMSCorrelationId() {
+ return jmsCorrelationId;
+ }
+
+ public void setJMSCorrelationId(String jmsCorrelationId) {
setHeaders( true );
- this.timeToLive = Long.valueOf(timeToLive);
+ this.jmsCorrelationId = jmsCorrelationId;
}
public Set<String> getPropertyNames() {
@@ -621,7 +665,7 @@ public class JMSBinding implements Binding, PolicySubject, OperationsConfigurato
if (operationJMSTypes.containsKey(opName)) {
return operationJMSTypes.get(opName);
} else {
- return jmsType;
+ return null;
}
}
}
@@ -653,13 +697,13 @@ public class JMSBinding implements Binding, PolicySubject, OperationsConfigurato
if (operationPropertiesBinding.getOperationJMSDeliveryMode(opName) != null) {
return operationPropertiesBinding.getOperationJMSDeliveryMode(opName);
} else {
- return deliveryModePersistent;
+ return null;
}
} else {
if (operationJMSDeliveryModes.containsKey(opName)) {
return operationJMSDeliveryModes.get(opName);
} else {
- return deliveryModePersistent;
+ return null;
}
}
}
@@ -672,13 +716,13 @@ public class JMSBinding implements Binding, PolicySubject, OperationsConfigurato
if (operationPropertiesBinding.getOperationJMSTimeToLive(opName) != null) {
return operationPropertiesBinding.getOperationJMSTimeToLive(opName);
} else {
- return timeToLive;
+ return null;
}
} else {
if (operationJMSTimeToLives.containsKey(opName)) {
return operationJMSTimeToLives.get(opName);
} else {
- return timeToLive;
+ return null;
}
}
}
@@ -691,13 +735,13 @@ public class JMSBinding implements Binding, PolicySubject, OperationsConfigurato
if (operationPropertiesBinding.getOperationJMSPriority(opName) != null) {
return operationPropertiesBinding.getOperationJMSPriority(opName);
} else {
- return jmsPriority;
+ return null;
}
} else {
if (operationJMSPriorities.containsKey(opName)) {
return operationJMSPriorities.get(opName);
} else {
- return jmsPriority;
+ return null;
}
}
}
@@ -979,4 +1023,50 @@ public class JMSBinding implements Binding, PolicySubject, OperationsConfigurato
public void setJMSURI(String jmsURI) {
this.jmsURI = jmsURI;
}
+
+
+ public void setURIJMSDeliveryMode(boolean equals) {
+ this.uriDeliveryMode = Boolean.valueOf(equals);
+ }
+
+ public Integer getURIJMSPriority() {
+ return this.uriJMSPriority;
+ }
+
+ public void setURIJMSPriority(int parseInt) {
+ this.uriJMSPriority = Integer.valueOf(parseInt);
+ }
+
+ public Long getURIJMSTimeToLive() {
+ return this.uriJMSTimeToLive;
+ }
+ public void setURIJMSTimeToLive(long parseLong) {
+ this.uriJMSTimeToLive = Long.valueOf(parseLong);
+ }
+
+ public Boolean isHeaderDeliveryModePersistent() {
+ return this.headerDeliveryMode;
+ }
+ public void setJMSHeaderDeliveryMode(boolean b) {
+ this.headerDeliveryMode = Boolean.valueOf(b);
+ }
+
+ public Long getJMSHeaderTimeToLive() {
+ return this.headerTimeToLive;
+ }
+ public void setJMSHeaderTimeToLive(long parseLong) {
+ this.headerTimeToLive = Long.valueOf(parseLong);
+ }
+
+ public Integer getJMSHeaderPriority() {
+ return this.headerPriority;
+ }
+ public void setJMSHeaderPriority(int p) {
+ this.headerPriority = Integer.valueOf(p);
+ }
+
+ public Integer getDefaultJMSPriority() {
+ return this.defaultPriority;
+ }
+
}
diff --git a/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java b/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java
index 9ea6b3a001..0dffea12b5 100644
--- a/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java
+++ b/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java
@@ -368,13 +368,11 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St
if (s.startsWith("connectionFactoryName=")) {
jmsBinding.setConnectionFactoryName(s.substring(22));
} else if (s.startsWith("deliveryMode=")) {
- jmsBinding.setJMSDeliveryMode("persistent".equals(s.substring(13)));
+ jmsBinding.setURIJMSDeliveryMode("persistent".equals(s.substring(13)));
} else if (s.startsWith("priority=")) {
- jmsBinding.setJMSPriority(Integer.parseInt(s.substring(9)));
+ jmsBinding.setURIJMSPriority(Integer.parseInt(s.substring(9)));
} else if (s.startsWith("timeToLive=")) {
- jmsBinding.setJMSTimeToLive(Long.parseLong(s.substring(11)));
- } else if (s.startsWith("type=")) {
- jmsBinding.setJMSType((s.substring(5)));
+ jmsBinding.setURIJMSTimeToLive(Long.parseLong(s.substring(11)));
} else if (s.startsWith("selector='")) {
String selector = s.substring(10);
if (selector.startsWith("\"") || selector.startsWith("'")) {
@@ -384,11 +382,14 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St
selector = selector.substring(0, selector.length() - 1);
}
jmsBinding.setJMSSelector(selector);
- } else {
- error(monitor, "UnknownTokenInURI", jmsBinding, s, uri);
- return;
- }
- }
+ } else if (s.startsWith("type")) {
+ String type = s.substring(5);
+ jmsBinding.setJMSURIType(type);
+ } else {
+ error(monitor, "UnknownTokenInURI", jmsBinding, s, uri);
+ return;
+ }
+ }
int j=uri.indexOf(':', 4);
jmsBinding.setDestinationName(uri.substring(j+1, i));
jmsBinding.setDestinationType(uri.substring(4, j));
@@ -673,15 +674,15 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St
private void parseHeaders(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
String jmsType = reader.getAttributeValue(null, "type");
if (jmsType != null && jmsType.length() > 0) {
- jmsBinding.setJMSType(jmsType);
+ jmsBinding.setJMSHeaderType(jmsType);
}
String jmsDeliveryMode = reader.getAttributeValue(null, "deliveryMode");
if (jmsDeliveryMode != null && jmsDeliveryMode.length() > 0) {
if ("persistent".equalsIgnoreCase(jmsDeliveryMode)) {
- jmsBinding.setJMSDeliveryMode(true);
+ jmsBinding.setJMSHeaderDeliveryMode(true);
} else if ("nonpersistent".equalsIgnoreCase(jmsDeliveryMode)) {
- jmsBinding.setJMSDeliveryMode(false);
+ jmsBinding.setJMSHeaderDeliveryMode(false);
} else {
error(monitor, "InvalidJMSDeliveryMode", jmsBinding, jmsDeliveryMode);
}
@@ -689,7 +690,7 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St
String jmsTimeToLive = reader.getAttributeValue(null, "timeToLive");
if (jmsTimeToLive != null && jmsTimeToLive.length() > 0) {
- jmsBinding.setJMSTimeToLive(Long.parseLong(jmsTimeToLive));
+ jmsBinding.setJMSHeaderTimeToLive(Long.parseLong(jmsTimeToLive));
}
String jmsPriority = reader.getAttributeValue(null, "priority");
@@ -697,7 +698,7 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St
try {
int p = Integer.parseInt(jmsPriority);
if (p >= 0 && p <= 9) {
- jmsBinding.setJMSPriority(p);
+ jmsBinding.setJMSHeaderPriority(p);
} else {
warning(monitor, "InvalidJMSPriority", jmsBinding, jmsPriority);
}
@@ -1151,12 +1152,12 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St
writer.writeStartElement(Constants.SCA11_NS, JMSBindingConstants.HEADERS);
- String jmsType = jmsBinding.getJMSType();
+ String jmsType = jmsBinding.getJMSHeaderType();
if (jmsType != null && jmsType.length() > 0) {
writer.writeAttribute("type", jmsType);
}
- Boolean jmsDeliveryMode = jmsBinding.isdeliveryModePersistent();
+ Boolean jmsDeliveryMode = jmsBinding.isHeaderDeliveryModePersistent();
if (jmsDeliveryMode != null) {
if ( jmsDeliveryMode.booleanValue() )
writer.writeAttribute("deliveryMode", "persistent");
@@ -1164,12 +1165,12 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St
writer.writeAttribute("deliveryMode", "nonpersistent");
}
- Long jmsTimeToLive = jmsBinding.getJMSTimeToLive();
+ Long jmsTimeToLive = jmsBinding.getJMSHeaderTimeToLive();
if (jmsTimeToLive != null) {
writer.writeAttribute("timeToLive", jmsTimeToLive.toString());
}
- Integer jmsPriority = jmsBinding.getJMSPriority();
+ Integer jmsPriority = jmsBinding.getJMSHeaderPriority();
if (jmsPriority != null) {
writer.writeAttribute("priority", jmsPriority.toString());
}
diff --git a/sca-java-2.x/trunk/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java b/sca-java-2.x/trunk/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java
index e945da22e2..c1fb89df8d 100644
--- a/sca-java-2.x/trunk/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java
+++ b/sca-java-2.x/trunk/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java
@@ -426,10 +426,10 @@ public class JMSBindingProcessorTestCase extends TestCase {
JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
assertNotNull(binding);
- assertEquals("myType", binding.getJMSType());
- assertTrue(binding.isdeliveryModePersistent());
- assertEquals(54321, binding.getJMSTimeToLive().longValue());
- assertEquals(5, binding.getJMSPriority().intValue());
+ assertEquals("myType", binding.getJMSHeaderType());
+ assertTrue(binding.isHeaderDeliveryModePersistent());
+ assertEquals(54321, binding.getJMSHeaderTimeToLive().longValue());
+ assertEquals(5, binding.getJMSHeaderPriority().intValue());
}
public void testProperties1() throws Exception {