You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2008/07/16 15:51:30 UTC
svn commit: r677287 -
/tuscany/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java
Author: antelder
Date: Wed Jul 16 06:51:28 2008
New Revision: 677287
URL: http://svn.apache.org/viewvc?rev=677287&view=rev
Log:
Refactoring of JMS listener
Modified:
tuscany/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java
Modified: tuscany/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java?rev=677287&r1=677286&r2=677287&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java (original)
+++ tuscany/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java Wed Jul 16 06:51:28 2008
@@ -59,6 +59,7 @@
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 @@
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 @@
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 @@
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);
-
- from.setCallbackEndpoint(new EndpointReferenceImpl("/")); // TODO: whats this for?
+ EndpointReference from = new EndpointReferenceImpl(null);
+ tuscanyMsg.setFrom(from);
+ from.setCallbackEndpoint(new EndpointReferenceImpl("/")); // TODO: whats this for?
+ ReferenceParameters parameters = from.getReferenceParameters();
+
+ 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 @@
if (callbackID != null) {
parameters.setCallbackID(callbackID);
}
-
- String conversationID = requestJMSMsg.getStringProperty(JMSBindingConstants.CONVERSATION_ID_PROPERTY);
- if (conversationID != null) {
- parameters.setConversationID(conversationID);
- }
}
}