You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/10/20 06:46:23 UTC

svn commit: r465988 - in /incubator/tuscany/java/sca/kernel: core/src/main/java/org/apache/tuscany/core/implementation/java/ core/src/main/java/org/apache/tuscany/core/wire/jdk/ core/src/test/java/org/apache/tuscany/core/wire/ core/src/test/java/org/ap...

Author: jmarino
Date: Thu Oct 19 21:46:22 2006
New Revision: 465988

URL: http://svn.apache.org/viewvc?view=rev&rev=465988
Log:
[Patch] for Tuscany-642 SimplerCompositeReferenceInvocation3.patch from Ignacio; committing kernel portions first, and then Axis changes to avoid mixing unrelated in-progress changes that I have on my local machine

Modified:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/AsyncJavaTargetInvoker.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/BasicReferenceInvocationHandlerTestCase.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationErrorTestCase.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationHandlerTestCase.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/AsyncJavaTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/AsyncJavaTargetInvoker.java?view=diff&rev=465988&r1=465987&r2=465988
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/AsyncJavaTargetInvoker.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/AsyncJavaTargetInvoker.java Thu Oct 19 21:46:22 2006
@@ -65,9 +65,11 @@
     public Message invoke(Message msg) throws InvocationRuntimeException {
         try {
             Object messageId = msg.getMessageId();
-            wire.addMapping(messageId, msg.getFromAddress());
-            workContext.setCurrentMessageId(null);
-            workContext.setCurrentCorrelationId(messageId);
+            if (messageId != null) {
+                wire.addMapping(messageId, msg.getFromAddress());
+                workContext.setCurrentMessageId(null);
+                workContext.setCurrentCorrelationId(messageId);
+            }
             invokeTarget(msg.getBody());
             // async so no return value
             return null;

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java?view=diff&rev=465988&r1=465987&r2=465988
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java Thu Oct 19 21:46:22 2006
@@ -24,10 +24,10 @@
 import java.util.Map;
 
 import org.apache.tuscany.spi.component.TargetException;
-import org.apache.tuscany.spi.component.WorkContext;
 import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
 import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.wire.AbstractOutboundInvocationHandler;
+import org.apache.tuscany.spi.wire.MessageId;
 import org.apache.tuscany.spi.wire.OutboundInvocationChain;
 import org.apache.tuscany.spi.wire.OutboundWire;
 import org.apache.tuscany.spi.wire.TargetInvoker;
@@ -51,17 +51,18 @@
      * is not cacheable, the master associated with the wire chains will be used.
      */
     private Map<Method, ChainHolder> chains;
-    private WorkContext context;
     private Object fromAddress;
     private Object messageId;
     private Object correlationId;
+    private boolean contractHasCallback;
 
-    public JDKOutboundInvocationHandler(OutboundWire wire, WorkContext context)
+    public JDKOutboundInvocationHandler(OutboundWire wire)
         throws NoMethodForOperationException {
         Map<Operation<?>, OutboundInvocationChain> invocationChains = wire.getInvocationChains();
         this.chains = new HashMap<Method, ChainHolder>(invocationChains.size());
         this.fromAddress = (wire.getContainer() == null) ? null : wire.getContainer().getName();
         Method[] methods = wire.getServiceContract().getInterfaceClass().getMethods();
+        this.contractHasCallback = wire.getServiceContract().getCallbackClass() != null;
         // TODO optimize this
         for (Map.Entry<Operation<?>, OutboundInvocationChain> entry : invocationChains.entrySet()) {
             Operation operation = entry.getKey();
@@ -71,8 +72,6 @@
             }
             this.chains.put(method, new ChainHolder(entry.getValue()));
         }
-
-        this.context = context;
     }
 
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
@@ -114,10 +113,7 @@
             assert chain != null;
             invoker = chain.getTargetInvoker();
         }
-        messageId = context.getCurrentMessageId();
-        context.setCurrentMessageId(null);
-        correlationId = context.getCurrentCorrelationId();
-        context.setCurrentCorrelationId(null);
+        messageId = (contractHasCallback ? new MessageId() : null);
         return invoke(chain, invoker, args);
     }
 

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java?view=diff&rev=465988&r1=465987&r2=465988
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java Thu Oct 19 21:46:22 2006
@@ -97,7 +97,7 @@
             return Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler);
         } else if (wire instanceof OutboundWire) {
             OutboundWire outbound = (OutboundWire) wire;
-            JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(outbound, context);
+            JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(outbound);
             Class<?> interfaze = outbound.getServiceContract().getInterfaceClass();
             ClassLoader cl = interfaze.getClassLoader();
             return Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler);
@@ -124,7 +124,7 @@
             return new JDKInboundInvocationHandler(chains, context);
         } else if (wire instanceof OutboundWire) {
             OutboundWire outbound = (OutboundWire) wire;
-            return new JDKOutboundInvocationHandler(outbound, context);
+            return new JDKOutboundInvocationHandler(outbound);
         } else {
             ProxyCreationException e = new ProxyCreationException("Invalid wire type");
             e.setIdentifier(wire.getClass().getName());

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/BasicReferenceInvocationHandlerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/BasicReferenceInvocationHandlerTestCase.java?view=diff&rev=465988&r1=465987&r2=465988
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/BasicReferenceInvocationHandlerTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/BasicReferenceInvocationHandlerTestCase.java Thu Oct 19 21:46:22 2006
@@ -27,7 +27,6 @@
 import org.apache.tuscany.spi.wire.OutboundWire;
 
 import junit.framework.TestCase;
-import org.apache.tuscany.core.component.WorkContextImpl;
 import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
 import org.apache.tuscany.core.mock.component.SimpleTarget;
 import org.apache.tuscany.core.mock.component.SimpleTargetImpl;
@@ -57,7 +56,7 @@
         OutboundWire wire = new OutboundWireImpl();
         wire.addInvocationChain(operation, chain);
         wire.setServiceContract(contract);
-        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire);
         assertEquals("foo", handler.invoke(null, echo, new String[]{"foo"}));
         assertEquals(1, interceptor.getCount());
     }

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationErrorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationErrorTestCase.java?view=diff&rev=465988&r1=465987&r2=465988
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationErrorTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationErrorTestCase.java Thu Oct 19 21:46:22 2006
@@ -29,7 +29,6 @@
 
 import junit.framework.TestCase;
 
-import org.apache.tuscany.core.component.WorkContextImpl;
 import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
 import org.apache.tuscany.core.mock.wire.MockStaticInvoker;
 import org.apache.tuscany.core.mock.wire.MockSyncInterceptor;
@@ -68,7 +67,7 @@
         wire.setServiceContract(contract);
         Operation operation = contract.getOperations().get("checkedException");
         wire.addInvocationChain(operation, createChain(checkedMethod, operation));
-        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire);
         try {
             TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
                 new Class[]{TestBean.class}, handler);
@@ -86,7 +85,7 @@
         Operation operation = contract.getOperations().get("runtimeException");
         OutboundInvocationChain chain = createChain(runtimeMethod, operation);
         wire.addInvocationChain(operation, chain);
-        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire);
         try {
             TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
                 new Class[]{TestBean.class}, handler);

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationHandlerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationHandlerTestCase.java?view=diff&rev=465988&r1=465987&r2=465988
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationHandlerTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/OutboundInvocationHandlerTestCase.java Thu Oct 19 21:46:22 2006
@@ -29,7 +29,6 @@
 import org.apache.tuscany.spi.wire.OutboundWire;
 
 import junit.framework.TestCase;
-import org.apache.tuscany.core.component.WorkContextImpl;
 import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
 import org.apache.tuscany.core.mock.component.SimpleTarget;
 import org.apache.tuscany.core.mock.component.SimpleTargetImpl;
@@ -62,7 +61,7 @@
         Operation operation = contract.getOperations().get("hello");
         wire.addInvocationChain(operation, createChain(operation));
         wire.setServiceContract(contract);
-        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire);
         assertEquals("foo", handler.invoke(hello, new Object[]{"foo"}));
     }
 
@@ -71,7 +70,7 @@
         Operation operation = contract.getOperations().get("hello");
         wire.addInvocationChain(operation, createChain(operation));
         wire.setServiceContract(contract);
-        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire);
         try {
             handler.invoke(hello, new Object[]{});
             fail("Expected " + IllegalArgumentException.class.getName());
@@ -89,7 +88,7 @@
         OutboundWire wire = new OutboundWireImpl();
         wire.setServiceContract(contract);
         wire.addInvocationChain(operation, source);
-        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire);
         try {
             assertEquals("foo", handler.invoke(hello, new Object[]{}));
             fail("Expected " + IllegalArgumentException.class.getName());
@@ -107,7 +106,7 @@
         OutboundWire wire = new OutboundWireImpl();
         wire.setServiceContract(contract);
         wire.addInvocationChain(operation, source);
-        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire);
         assertEquals("foo", handler.invoke(hello, new Object[]{"foo"}));
     }
 

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java?view=diff&rev=465988&r1=465987&r2=465988
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java Thu Oct 19 21:46:22 2006
@@ -24,7 +24,6 @@
 
 import junit.framework.TestCase;
 
-import org.apache.tuscany.core.component.WorkContextImpl;
 import org.apache.tuscany.core.wire.OutboundWireImpl;
 
 /**
@@ -35,7 +34,7 @@
     public void testToString() {
         OutboundWireImpl wire = new OutboundWireImpl();
         wire.setServiceContract(new JavaServiceContract(Foo.class));
-        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire);
         Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler);
         assertNotNull(foo.toString());
     }
@@ -43,7 +42,7 @@
     public void testHashCode() {
         OutboundWireImpl wire = new OutboundWireImpl();
         wire.setServiceContract(new JavaServiceContract(Foo.class));
-        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
+        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire);
         Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler);
         assertNotNull(foo.hashCode());
     }

Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java?view=diff&rev=465988&r1=465987&r2=465988
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java Thu Oct 19 21:46:22 2006
@@ -52,12 +52,13 @@
                 msg.setFromAddress(fromAddress);
             }
             Object messageId = getMessageId();
-            if (messageId == null) {
-                messageId = new MessageId();
+            if (messageId != null) {
+                msg.setMessageId(messageId);
             }
-            msg.setMessageId(messageId);
             Object corrId = getCorrelationId();
-            msg.setCorrelationId(corrId);
+            if (corrId != null) {
+                msg.setCorrelationId(corrId);
+            }
             msg.setBody(args);
             // dispatch the wire down the chain and get the response
             Message resp = headInterceptor.invoke(msg);



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org