summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject
diff options
context:
space:
mode:
Diffstat (limited to 'branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject')
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java31
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java23
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java24
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java26
4 files changed, 93 insertions, 11 deletions
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java
index 6ba62d7681..22c66b0b78 100644
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java
+++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java
@@ -20,6 +20,8 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime;
import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+
import javax.jms.JMSException;
import javax.jms.Session;
@@ -31,6 +33,7 @@ import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException;
import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.provider.ObjectMessageProcessor;
import org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObject;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Invoker;
@@ -50,13 +53,16 @@ public class WireFormatJMSObjectReferenceInterceptor implements Interceptor {
private JMSMessageProcessor requestMessageProcessor;
private JMSMessageProcessor responseMessageProcessor;
- public WireFormatJMSObjectReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
+ private HashMap<String, String> singleArgMap;
+
+ public WireFormatJMSObjectReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire, HashMap<String, String> hashMap) {
super();
this.jmsBinding = jmsBinding;
this.runtimeWire = runtimeWire;
this.jmsResourceFactory = jmsResourceFactory;
this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding);
+ this.singleArgMap = hashMap;
}
public Message invoke(Message msg) {
@@ -78,8 +84,27 @@ public class WireFormatJMSObjectReferenceInterceptor implements Interceptor {
// get the jms context
JMSBindingContext context = msg.getBindingContext();
Session session = context.getJmsSession();
-
- javax.jms.Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
+
+ javax.jms.Message requestMsg;
+
+ // Tuscany automatically wraps operation arguments in an array before we
+ // get to this point so here we need to decide how they are going to appear
+ // on the wire.
+ //
+ // If the operation has a single parameter and the user has set @wrapSingle=false
+ // then
+ // send the single parameter out onto the wire unwrapped
+ // else
+ // send out the message as is
+ //
+ if (singleArgMap.get(msg.getOperation().getName()) == null) {
+ requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
+ } else {
+ // we know that wrapSinle is set to false here as the provider only
+ // populates singleArgMap if it is set false
+ requestMsg = ((ObjectMessageProcessor) requestMessageProcessor).createJMSMessageForSingleParamOperation(session, msg.getBody(), false);
+ }
+
msg.setBody(requestMsg);
requestMsg.setJMSReplyTo(context.getReplyToDestination());
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java
index 644c9ebc38..702293301b 100644
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java
+++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java
@@ -19,12 +19,16 @@
package org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime;
+import java.util.HashMap;
+import java.util.List;
+
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants;
import org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObject;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
import org.apache.tuscany.sca.provider.WireFormatProvider;
@@ -40,6 +44,8 @@ public class WireFormatJMSObjectReferenceProvider implements WireFormatProvider
private RuntimeComponentReference reference;
private JMSBinding binding;
private InterfaceContract interfaceContract;
+
+ private HashMap<String,String> singleArgMap; //map of one arg operations, leave empty if wrapSingleInput is true
public WireFormatJMSObjectReferenceProvider(ExtensionPointRegistry registry,
RuntimeComponent component,
@@ -51,6 +57,8 @@ public class WireFormatJMSObjectReferenceProvider implements WireFormatProvider
this.reference = reference;
this.binding = (JMSBinding)binding;
+ this.singleArgMap = new HashMap<String,String>();
+
// configure the reference based on this wire format
// currently maintaining the message processor structure which
@@ -58,10 +66,21 @@ public class WireFormatJMSObjectReferenceProvider implements WireFormatProvider
// any message processors specified in the SCDL in this case
if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){
this.binding.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME);
+
+ //we don't need to create this map if wrapSingleInput is true
+ if (!((WireFormatJMSObject) this.binding.getRequestWireFormat()).isWrappedSingleInput()){
+ List<Operation> opList = reference.getReference().getInterfaceContract().getInterface().getOperations();
+
+ for (Operation op: opList) {
+ if (op.getInputType().getLogical().size() == 1){
+ this.singleArgMap.put(op.getName(), "");
+ }
+ }
+ }
}
if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){
this.binding.setResponseMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME);
- }
+ }
// just point to the reference interface contract so no
// databinding transformation takes place
@@ -87,7 +106,7 @@ public class WireFormatJMSObjectReferenceProvider implements WireFormatProvider
public Interceptor createInterceptor() {
return new WireFormatJMSObjectReferenceInterceptor(binding,
null,
- reference.getRuntimeWire(binding));
+ reference.getRuntimeWire(binding), this.singleArgMap);
}
public String getPhase() {
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java
index b063f8d53b..5979bc9214 100644
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java
+++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java
@@ -18,6 +18,8 @@
*/
package org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime;
+import java.util.HashMap;
+
import javax.jms.Session;
import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
@@ -25,6 +27,7 @@ import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.provider.ObjectMessageProcessor;
import org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObject;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
@@ -45,14 +48,19 @@ public class WireFormatJMSObjectServiceInterceptor implements Interceptor {
private JMSBinding jmsBinding;
private JMSMessageProcessor requestMessageProcessor;
private JMSMessageProcessor responseMessageProcessor;
+ private HashMap<String,Class<?>> singleArgMap;
+ private boolean wrapSingle;
- public WireFormatJMSObjectServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
+ public WireFormatJMSObjectServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory,
+ RuntimeWire runtimeWire, HashMap<String, Class<?>> singleArgMap, boolean wrapSingle) {
super();
this.jmsBinding = jmsBinding;
this.runtimeWire = runtimeWire;
this.jmsResourceFactory = jmsResourceFactory;
this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding);
+ this.singleArgMap = singleArgMap;
+ this.wrapSingle = wrapSingle;
}
public Message invoke(Message msg) {
@@ -79,8 +87,18 @@ public class WireFormatJMSObjectServiceInterceptor implements Interceptor {
// get the jms context
JMSBindingContext context = msg.getBindingContext();
javax.jms.Message jmsMsg = context.getJmsMsg();
-
- Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg);
+ Object requestPayload;
+
+ // If the service interface has a single argument then we need
+ // to check if the object from the wire is expected
+ // to be unwrapped or not
+ //
+ Class<?> argType = this.singleArgMap.get(msg.getOperation().getName());
+ if (argType == null) {
+ requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg);
+ }else {
+ requestPayload = ((ObjectMessageProcessor)requestMessageProcessor).extractPayloadFromJMSMessageForSingleParamOperation(jmsMsg, argType, wrapSingle);
+ }
if (requestPayload != null && requestPayload.getClass().isArray()) {
msg.setBody(requestPayload);
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java
index e5887ec1b7..dc4726f4b7 100644
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java
+++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java
@@ -20,12 +20,16 @@
package org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime;
+import java.util.HashMap;
+import java.util.List;
+
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants;
import org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObject;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
import org.apache.tuscany.sca.provider.WireFormatProvider;
@@ -41,6 +45,8 @@ public class WireFormatJMSObjectServiceProvider implements WireFormatProvider {
private RuntimeComponentService service;
private JMSBinding binding;
private InterfaceContract interfaceContract;
+ private HashMap<String,Class<?>> singleArgMap;
+ private boolean wrapSingle = true;
public WireFormatJMSObjectServiceProvider(ExtensionPointRegistry registry,
RuntimeComponent component,
@@ -51,6 +57,7 @@ public class WireFormatJMSObjectServiceProvider implements WireFormatProvider {
this.component = component;
this.service = service;
this.binding = (JMSBinding)binding;
+ this.singleArgMap = new HashMap<String,Class<?>>();
// configure the service based on this wire format
@@ -59,6 +66,17 @@ public class WireFormatJMSObjectServiceProvider implements WireFormatProvider {
// any message processors specified in the SCDL in this case
if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){
this.binding.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME);
+
+ List<Operation> opList = service.getService().getInterfaceContract().getInterface().getOperations();
+
+ for (Operation op: opList) {
+ if (op.getInputType().getLogical().size() == 1){
+ this.singleArgMap.put(op.getName(), op.getInputType().getLogical().get(0).getPhysical());
+ }
+ }
+
+ wrapSingle = ((WireFormatJMSObject) this.binding.getRequestWireFormat()).isWrappedSingleInput();
+
}
if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){
this.binding.setResponseMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME);
@@ -67,6 +85,8 @@ public class WireFormatJMSObjectServiceProvider implements WireFormatProvider {
// just point to the reference interface contract so no
// databinding transformation takes place
interfaceContract = service.getInterfaceContract();
+
+
}
public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){
@@ -88,9 +108,9 @@ public class WireFormatJMSObjectServiceProvider implements WireFormatProvider {
/**
*/
public Interceptor createInterceptor() {
- return new WireFormatJMSObjectServiceInterceptor((JMSBinding)binding,
- null,
- service.getRuntimeWire(binding));
+
+ return new WireFormatJMSObjectServiceInterceptor((JMSBinding)binding, null,service.getRuntimeWire(binding),
+ this.singleArgMap, wrapSingle );
}
/**