summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/core/src/main/java
diff options
context:
space:
mode:
authorscottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68>2011-01-20 14:57:06 +0000
committerscottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68>2011-01-20 14:57:06 +0000
commitde7789044d196dfadab3b8ddfddf2f26f7a1bbd8 (patch)
treea2eef7b87fb6b98af951c68a188ceb9ac5977f47 /sca-java-2.x/trunk/modules/core/src/main/java
parent81ab42fb0730a787d799c870e09726ec1fb82116 (diff)
Fix for TUSCANY-3819 (still need to cleanup bare case, wsdlgen).
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1061329 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/core/src/main/java')
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java55
1 files changed, 47 insertions, 8 deletions
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
index df378e55a0..5bb2354520 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
@@ -23,6 +23,7 @@ import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
@@ -34,6 +35,7 @@ import org.apache.tuscany.sca.context.ThreadMessageContext;
import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
import org.apache.tuscany.sca.interfacedef.DataType;
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;
@@ -109,15 +111,29 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable {
// Holder pattern. Items stored in a Holder<T> are promoted to T.
// After the invoke, the returned data <T> are placed back in Holder<T>.
- Object [] promotedArgs = promoteHolderArgs( args );
-
+ Object [] promotedArgs = promoteHolderArgs( args );
+
+ // Strip out OUT-only arguments. Not too sure if the presence
+ // of a sourceOperation is exactly the right check to use to
+ // know whether or not to do this, but will assume it is until
+ // learning otherwise.
+ Operation sourceOp = chain.getSourceOperation();
+ if (sourceOp != null) {
+ promotedArgs = removeOutOnlyArgs(sourceOp, promotedArgs );
+ }
+
Object result = invoke(chain, promotedArgs, source);
+ // TODO - Based on the code in JavaInterfaceIntrospectorImpl, it seems there are
+ // some cases involving generics that we're not taking into account.
+ boolean voidReturnType = (void.class == method.getReturnType() ? true : false);
+
// Returned Holder data <T> are placed back in Holder<T>.
boolean holderPattern = false;
Class [] parameters = method.getParameterTypes();
if ( parameters != null ) {
- for ( int i = 0, resultIdx = 0; i < parameters.length; i++ ) {
+ int resultIdx = (voidReturnType ? 0 : 1);
+ for ( int i = 0; i < parameters.length; i++ ) {
Class parameterType = parameters[ i ];
if ( isHolder( parameterType ) ) {
holderPattern = true;
@@ -126,15 +142,20 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable {
Object[] results = (Object[])result;
if ( result != null ) {
- holder.value = results[++resultIdx];
+ holder.value = results[resultIdx++];
}
}
}
}
- if ( holderPattern && result != null)
- return ((Object[])result)[0];
- else
- return result;
+ if (holderPattern && result != null) {
+ if (voidReturnType) {
+ return null;
+ } else {
+ return ((Object[])result)[0];
+ }
+ } else {
+ return result;
+ }
}
/**
@@ -361,6 +382,24 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable {
}
/**
+ * Given an argument array, filters out (removes) OUT-only parameters
+ * @param sourceOp
+ * @return array of filtered arguments
+ */
+ Object[] removeOutOnlyArgs(Operation sourceOp, Object[] args) {
+ if ( args == null )
+ return args;
+ ArrayList<Object> retValList = new ArrayList<Object>();
+ List<ParameterMode> parmList = sourceOp.getParameterModes();
+ for (int i = 0; i < args.length; i++) {
+ if (parmList.get(i) != ParameterMode.OUT) {
+ retValList.add(args[i]);
+ }
+ }
+ return retValList.toArray();
+ }
+
+ /**
* Given a Class, tells if it is a Holder by comparing to "javax.xml.ws.Holder"
* @param testClass
* @return boolean whether class is Holder type.