From 561690e6ecf5aa4eb7ddd1093ada36b0f0433cb4 Mon Sep 17 00:00:00 2001 From: rfeng Date: Thu, 23 Apr 2009 18:23:06 +0000 Subject: Improve the handling of INOUT and OUT parameters using JAX-WS Holder git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@768005 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/core/invocation/JDKInvocationHandler.java | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'branches/sca-java-1.x/modules/core/src/main/java') diff --git a/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java b/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java index 5bb648ce61..b2b30db558 100644 --- a/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java +++ b/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java @@ -46,6 +46,7 @@ import org.apache.tuscany.sca.interfacedef.DataType; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.ParameterMode; import org.apache.tuscany.sca.interfacedef.java.JavaOperation; import org.apache.tuscany.sca.invocation.InvocationChain; import org.apache.tuscany.sca.invocation.Invoker; @@ -154,18 +155,15 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { Object result = invoke(chain, args, wire, source); - Operation operation = chain.getTargetOperation(); + Operation operation = chain.getSourceOperation(); if (operation != null && operation.getInterface().isRemotable()) { + List inputTypes = operation.getInputType().getLogical(); // Returned Holder data are placed back in Holder. - Class[] parameters = method.getParameterTypes(); - if (parameters != null) { - for (int i = 0; i < parameters.length; i++) { - Class parameterType = parameters[i]; - if (Holder.class == parameterType) { - // Pop results and place in holder (demote). - Holder holder = (Holder)args[i]; - holder.value = result; - } + for (int i = 0, size = inputTypes.size(); i < size; i++) { + if (operation.getParameterModes().get(i) != ParameterMode.IN) { + // Pop results and place in holder (demote). + Holder holder = (Holder)args[i]; + holder.value = result; } } } @@ -295,7 +293,7 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { // Holder pattern. Items stored in a Holder are promoted to T. // After the invoke, the returned data are placed back in Holder. if (operation != null && operation.getInterface().isRemotable()) { - args = promoteHolderArgs(args); + args = promoteHolderArgs(chain.getSourceOperation(), args); } msg.setBody(args); @@ -543,16 +541,16 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { * @param args containing Holders and other objects. * @return Object [] */ - protected static Object[] promoteHolderArgs(Object[] args) { + protected static Object[] promoteHolderArgs(Operation operation, Object[] args) { if (args == null) return args; Object[] promotedArgs = new Object[args.length]; - + List modes = operation.getParameterModes(); for (int i = 0; i < args.length; i++) { Object argument = args[i]; if (argument != null) { - if (isHolder(argument)) { + if (modes.get(i) != ParameterMode.IN) { promotedArgs[i] = ((Holder)argument).value; } else { promotedArgs[i] = args[i]; -- cgit v1.2.3