tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r667121 - in /incubator/tuscany/java/sca: itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/ modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ modules/implementation-java-runtime/src/main/java/org/ap...
Date Thu, 12 Jun 2008 14:57:17 GMT
Author: nash
Date: Thu Jun 12 07:57:16 2008
New Revision: 667121

URL: http://svn.apache.org/viewvc?rev=667121&view=rev
Log:
Fix problem when conversation ends abnormally because of system exception

Modified:
    incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvBadCallback.java
    incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvClientImpl.java
    incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvNonSerCallback.java
    incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvObjectCallback.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java

Modified: incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvBadCallback.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvBadCallback.java?rev=667121&r1=667120&r2=667121&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvBadCallback.java
(original)
+++ incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvBadCallback.java
Thu Jun 12 07:57:16 2008
@@ -18,9 +18,11 @@
  */
 package org.apache.tuscany.sca.test;
 
+import java.io.Serializable;
+
 import junit.framework.Assert;
 
-public class CallBackSetCallbackConvBadCallback {
+public class CallBackSetCallbackConvBadCallback implements Serializable {
 
     public CallBackSetCallbackConvBadCallback() {
         super();
@@ -32,7 +34,6 @@
         //
         System.out.println("CallBackSetCallbackBadCallback: callback called");
         Assert.fail("CallBackSetCallbackConvBadCallback: callback called");
-        return;
     }
 
 }

Modified: incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvClientImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvClientImpl.java?rev=667121&r1=667120&r2=667121&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvClientImpl.java
(original)
+++ incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvClientImpl.java
Thu Jun 12 07:57:16 2008
@@ -29,14 +29,14 @@
 
 @Service(CallBackSetCallbackConvClient.class)
 @Scope("CONVERSATION")
-public class CallBackSetCallbackConvClientImpl implements CallBackSetCallbackConvClient,
-        //FIXME: remove the following hack, needed to get around current JavaImplementationInvoker
limitation
-        CallBackSetCallbackConvCallback {
+public class CallBackSetCallbackConvClientImpl implements CallBackSetCallbackConvClient {
 
     @Context
     protected ComponentContext componentContext;
+
     @Reference
     protected CallBackSetCallbackConvService aCallBackService;
+
     private CallBackSetCallbackConvObjectCallback aCallbackObject = null;
 
     public void run() {
@@ -84,7 +84,7 @@
         ServiceReference<CallBackSetCallbackConvService> aCallBackServiceRef
                 = componentContext.cast(aCallBackService);
         aCallBackServiceRef.setCallback(aCallbackObject);
-        aCallBackService.knockKnock("Knock Knock");
+        aCallBackService.knockKnock("Knock Knock 7");
 
         Assert.assertEquals("CallBackSetCallbackConv - Test7", 2, aCallbackObject.getCount());
 
@@ -105,7 +105,7 @@
             ServiceReference<CallBackSetCallbackConvService> aCallBackServiceRef
                     = componentContext.cast(aCallBackService);
             aCallBackServiceRef.setCallback(new CallBackSetCallbackConvBadCallback());
-            aCallBackService.knockKnock("Knock Knock");
+            aCallBackService.knockKnock("Knock Knock 8");
         }
 
         //
@@ -143,12 +143,12 @@
             ServiceReference<CallBackSetCallbackConvService> aCallBackServiceRef
                     = componentContext.cast(aCallBackService);
             aCallBackServiceRef.setCallback(new CallBackSetCallbackConvNonSerCallback());
-            aCallBackService.knockKnock("Knock Knock");
+            aCallBackService.knockKnock("Knock Knock 9");
         }
         //
         // This should catch an appropriate exception.
         //
-        catch (IllegalStateException goodEx)
+        catch (IllegalArgumentException goodEx)
         {
             System.out.println("correct exception " + goodEx);
             correctException = true;
@@ -160,14 +160,4 @@
 
     }
 
-    //FIXME: remove the following methods, needed to get around current JavaImplementationInvoker
limitation
-
-    public void callBackMessage(String aString) {
-        throw new IllegalStateException("CallbackSetCallbackConvClientImpl.callbackMessage
called");
-    }
-
-    public void callBackIncrement(String aString) {
-        throw new IllegalStateException("CallbackSetCallbackConvClientImpl.callbackIncrement
called");
-    }
-
 }

Modified: incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvNonSerCallback.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvNonSerCallback.java?rev=667121&r1=667120&r2=667121&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvNonSerCallback.java
(original)
+++ incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvNonSerCallback.java
Thu Jun 12 07:57:16 2008
@@ -18,10 +18,11 @@
  */
 package org.apache.tuscany.sca.test;
 
+import junit.framework.Assert;
+
 public class CallBackSetCallbackConvNonSerCallback implements CallBackSetCallbackConvCallback
{
 
     private int callBackCount = 0;
-    private Object monitor;
 
     public CallBackSetCallbackConvNonSerCallback() {
         super();
@@ -35,24 +36,21 @@
         return callBackCount;
     }
 
-    public void setMonitor(Object anObject) {
-        monitor = anObject;
-    }
-
     public void callBackMessage(String aString) {
-
+        //
+        // This callback method should never be called.
+        //
         System.out.println("Entering CallBackSetCallbackConvNonSerCallback callBackMessage:
" + aString);
-
+        Assert.fail("CallBackSetCallbackConvNonSerCallback: callbackMessage called");
     }
 
     public void callBackIncrement(String aString) {
-
-        System.out.println("Entering callback increment: " + aString);
-
-        synchronized (monitor) {
-            this.incrementCallBackCount();
-            monitor.notify();
-        }
+        //
+        // This callback method should never be called.
+        //
+        System.out.println("Entering callbackIncrement: " + aString);
+        this.incrementCallBackCount();
+        Assert.fail("CallBackSetCallbackConvNonSerCallback: callbackIncrement called");
     }
 
 }

Modified: incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvObjectCallback.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvObjectCallback.java?rev=667121&r1=667120&r2=667121&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvObjectCallback.java
(original)
+++ incubator/tuscany/java/sca/itest/callback-set-conversation/src/main/java/org/apache/tuscany/sca/test/CallBackSetCallbackConvObjectCallback.java
Thu Jun 12 07:57:16 2008
@@ -18,11 +18,9 @@
  */
 package org.apache.tuscany.sca.test;
 
+import java.io.Serializable;
 
-public class CallBackSetCallbackConvObjectCallback
-        //FIXME: remove the following hack, needed to get around current JavaImplementationInvoker
limitation
-        extends CallBackSetCallbackConvClientImpl
-        //implements CallBackSetCallbackConvCallback
+public class CallBackSetCallbackConvObjectCallback implements CallBackSetCallbackConvCallback,
Serializable
 {
     private int callBackCount = 0;
 

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java?rev=667121&r1=667120&r2=667121&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java
Thu Jun 12 07:57:16 2008
@@ -281,6 +281,7 @@
         conversationPreinvoke(msg, wire);
         handleCallback(msg, wire, currentConversationID);
         ThreadMessageContext.setMessageContext(msg);
+        boolean abnormalEndConversation = false;
         try {
             // dispatch the wire down the chain and get the response
             Message resp = headInvoker.invoke(msg);
@@ -299,7 +300,7 @@
                         }
                         
                         if (businessException == false){
-                            operation.setConversationSequence(ConversationSequence.CONVERSATION_END);
+                            abnormalEndConversation = true;
                         }
                     } catch (Exception ex){
                         // TODO - sure what the best course of action is here. We have
@@ -310,7 +311,7 @@
             }
             return body;
         } finally {
-            conversationPostInvoke(msg, wire);
+            conversationPostInvoke(msg, wire, abnormalEndConversation);
             ThreadMessageContext.setMessageContext(msgContext);
         }
     }
@@ -346,7 +347,7 @@
             }
         }
 
-        Interface interfaze = msg.getOperation().getInterface();
+        Interface interfaze = msg.getFrom().getCallbackEndpoint().getInterfaceContract().getInterface();
         if (callbackObject != null) {
             if (callbackObject instanceof ServiceReference) {
                 EndpointReference callbackRef = ((CallableReferenceImpl)callbackObject).getEndpointReference();
@@ -357,6 +358,10 @@
                         throw new IllegalArgumentException(
                                                            "Callback object for stateless
callback is not a ServiceReference");
                     } else {
+                        if (!(callbackObject instanceof Serializable)) {
+                            throw new IllegalArgumentException(
+                                          "Callback object for stateful callback is not Serializable");
+                        }
                         ScopeContainer scopeContainer = getConversationalScopeContainer(wire);
                         if (scopeContainer != null) {
                             InstanceWrapper wrapper = new CallbackObjectWrapper(callbackObject);
@@ -402,7 +407,7 @@
 
         // if this is a local wire then schedule conversation timeouts based on the timeout
         // parameters from the service implementation. If this isn't a local wire then
-        // the RuntimeWireInvker will take care of this
+        // the RuntimeWireInvoker will take care of this
         if (wire.getTarget().getComponent() != null){
             conversation.updateLastReferencedTime();
         }
@@ -418,13 +423,15 @@
      * @throws TargetDestructionException
      */
     @SuppressWarnings("unchecked")
-    private void conversationPostInvoke(Message msg, RuntimeWire wire) throws TargetDestructionException
{
+    private void conversationPostInvoke(Message msg, RuntimeWire wire, boolean abnormalEndConversation)
+                     throws TargetDestructionException {
         Operation operation = msg.getOperation();
         ConversationSequence sequence = operation.getConversationSequence();
         // We check that conversation has not already ended as there is only one
         // conversation manager in the runtime and so, in the case of remote bindings, 
         // the conversation will already have been stopped when we get back to the client
-        if ((sequence == ConversationSequence.CONVERSATION_END) && (conversation.getState()
!= ConversationState.ENDED)) {
+        if ((sequence == ConversationSequence.CONVERSATION_END || abnormalEndConversation)
&&
+            (conversation.getState() != ConversationState.ENDED)) {
 
             // remove conversation id from scope container
             ScopeContainer scopeContainer = getConversationalScopeContainer(wire);

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java?rev=667121&r1=667120&r2=667121&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
Thu Jun 12 07:57:16 2008
@@ -121,7 +121,7 @@
                 try {
                     imethod = JavaInterfaceUtil.findMethod(instance.getClass(), operation);
                 } catch (NoSuchMethodException e) {
-                    throw new IllegalArgumentException(e);
+                    throw new IllegalArgumentException("Callback object does not provide
method " + e.getMessage());
                 }
             }
             



Mime
View raw message