summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/binding-jms-runtime
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-07-16 13:51:28 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-07-16 13:51:28 +0000
commit17e0cc7c765502e6236a35aa534e2dc261f856f6 (patch)
tree8febb440351239bbf96fae54979020ddf316f5f3 /java/sca/modules/binding-jms-runtime
parent305938e64bdc8e278a31a35c94b60dc7b0e9b003 (diff)
Refactoring of JMS listener
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@677287 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/binding-jms-runtime')
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java55
1 files changed, 33 insertions, 22 deletions
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java
index 6f5f571cb5..f60542018a 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java
@@ -59,6 +59,7 @@ public class JMSBindingListener implements MessageListener {
private JMSMessageProcessor requestMessageProcessor;
private JMSMessageProcessor responseMessageProcessor;
private String correlationScheme;
+ private List<Operation> serviceOperations;
public JMSBindingListener(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeComponentService service) throws NamingException {
this.jmsBinding = jmsBinding;
@@ -67,6 +68,8 @@ public class JMSBindingListener implements MessageListener {
requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding);
correlationScheme = jmsBinding.getCorrelationScheme();
+ serviceOperations = service.getInterfaceContract().getInterface().getOperations();
+
}
public void onMessage(Message requestJMSMsg) {
@@ -93,24 +96,39 @@ public class JMSBindingListener implements MessageListener {
String operationName = requestMessageProcessor.getOperationName(requestJMSMsg);
Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(requestJMSMsg);
- List<Operation> opList = service.getInterfaceContract().getInterface().getOperations();
+ Operation operation = getTargetOperation(operationName);
+
+ MessageImpl tuscanyMsg = new MessageImpl();
+ tuscanyMsg.setBody(requestPayload);
+ tuscanyMsg.setOperation(operation);
+
+ setHeaderProperties(requestJMSMsg, tuscanyMsg, operation);
+
+ return service.getRuntimeWire(jmsBinding).invoke(operation, tuscanyMsg);
+ }
+ protected Operation getTargetOperation(String operationName) {
Operation operation = null;
- if (opList.size() == 1) {
+ if (serviceOperations.size() == 1) {
+
// SCA JMS Binding Specification - Rule 1.5.1 line 203
- operation = opList.get(0);
+ operation = serviceOperations.get(0);
+
} else if (operationName != null) {
+
// SCA JMS Binding Specification - Rule 1.5.1 line 205
- for (Operation op : opList) {
+ for (Operation op : serviceOperations) {
if (op.getName().equals(operationName)) {
operation = op;
break;
}
}
+
} else {
+
// SCA JMS Binding Specification - Rule 1.5.1 line 207
- for (Operation op : opList) {
+ for (Operation op : serviceOperations) {
if (op.getName().equals(ON_MESSAGE_METHOD_NAME)) {
operation = op;
break;
@@ -122,24 +140,22 @@ public class JMSBindingListener implements MessageListener {
throw new JMSBindingException("Can't find operation " + (operationName != null ? operationName : ON_MESSAGE_METHOD_NAME));
}
- MessageImpl tuscanyMsg = new MessageImpl();
- tuscanyMsg.setBody(requestPayload);
- tuscanyMsg.setOperation(operation);
-
- setHeaderProperties(requestJMSMsg, tuscanyMsg, operation);
-
- return service.getRuntimeWire(jmsBinding).invoke(operation, tuscanyMsg);
+ return operation;
}
protected void setHeaderProperties(Message requestJMSMsg, MessageImpl tuscanyMsg, Operation operation) throws JMSException {
- if (service.getInterfaceContract().getCallbackInterface() != null) {
- EndpointReference from = new EndpointReferenceImpl(null);
- tuscanyMsg.setFrom(from);
+ EndpointReference from = new EndpointReferenceImpl(null);
+ tuscanyMsg.setFrom(from);
+ from.setCallbackEndpoint(new EndpointReferenceImpl("/")); // TODO: whats this for?
+ ReferenceParameters parameters = from.getReferenceParameters();
- from.setCallbackEndpoint(new EndpointReferenceImpl("/")); // TODO: whats this for?
+ String conversationID = requestJMSMsg.getStringProperty(JMSBindingConstants.CONVERSATION_ID_PROPERTY);
+ if (conversationID != null) {
+ parameters.setConversationID(conversationID);
+ }
- ReferenceParameters parameters = from.getReferenceParameters();
+ if (service.getInterfaceContract().getCallbackInterface() != null) {
String callbackdestName = requestJMSMsg.getStringProperty(JMSBindingConstants.CALLBACK_Q_PROPERTY);
if (callbackdestName == null && operation.isNonBlocking()) {
@@ -161,11 +177,6 @@ public class JMSBindingListener implements MessageListener {
if (callbackID != null) {
parameters.setCallbackID(callbackID);
}
-
- String conversationID = requestJMSMsg.getStringProperty(JMSBindingConstants.CONVERSATION_ID_PROPERTY);
- if (conversationID != null) {
- parameters.setConversationID(conversationID);
- }
}
}