Author: rfeng
Date: Sat Sep  1 12:04:18 2007
New Revision: 571857

URL: http://svn.apache.org/viewvc?rev=571857&view=rev
Log:
Clean up the JavaImplementationInvoker

Modified:
    
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/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=571857&r1=571856&r2=571857&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
 Sat Sep  1 12:04:18 2007
@@ -22,7 +22,6 @@
 import java.lang.reflect.Method;
 
 import org.apache.tuscany.sca.core.context.InstanceWrapper;
-import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
 import org.apache.tuscany.sca.core.scope.ScopeContainer;
 import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
 import org.apache.tuscany.sca.core.scope.TargetResolutionException;
@@ -40,12 +39,13 @@
 public class JavaImplementationInvoker implements Invoker {
     private Method method;
 
+    @SuppressWarnings("unchecked")
     private final ScopeContainer scopeContainer;
 
     public JavaImplementationInvoker(Method method, RuntimeComponent 
component) {
         assert method != null : "Operation method cannot be null";
         this.method = method;
-        this.scopeContainer = ((ScopedRuntimeComponent) 
component).getScopeContainer();
+        this.scopeContainer = 
((ScopedRuntimeComponent)component).getScopeContainer();
     }
 
     /**
@@ -69,29 +69,23 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
     public Message invoke(Message msg) {
-        Object messageId = msg.getMessageID();
-        if (messageId != null) {
-            Message workContext = ThreadMessageContext.getMessageContext();
-            workContext.setCorrelationID(messageId);
-        }
-
         ConversationSequence sequence = msg.getConversationSequence();
         Object payload = msg.getBody();
-        
-        // FIXME: How to deal with other scopes
-        Message messageContext = ThreadMessageContext.getMessageContext();
-        Object contextId = messageContext.getConversationID();
+
+        Object contextId = msg.getConversationID();
         try {
+            // The following call might create a new conversation, as a 
result, the msg.getConversationID() might 
+            // return a new value
             InstanceWrapper wrapper = getInstance(sequence, contextId);
-            
+
             // detects whether the scope container has created a conversation 
Id. This will
             // happen in the case that the component has conversational scope 
but only the
             // callback interface is conversational
-            boolean cleanUpComponent = (contextId == null) && 
-                                       (messageContext.getConversationID() != 
null);
-            contextId = messageContext.getConversationID();
-            
+            boolean cleanUpComponent = (contextId == null) && 
(msg.getConversationID() != null);
+            contextId = msg.getConversationID();
+
             Object instance = wrapper.getInstance();
             Object ret;
             if (payload != null && !payload.getClass().isArray()) {
@@ -100,8 +94,7 @@
                 ret = method.invoke(instance, (Object[])payload);
             }
             scopeContainer.returnWrapper(wrapper, contextId);
-            if ((sequence == ConversationSequence.CONVERSATION_END) ||
-                (cleanUpComponent)){
+            if ((sequence == ConversationSequence.CONVERSATION_END) || 
(cleanUpComponent)) {
                 // if end conversation, or we have the special case where a 
conversational
                 // object was created to service stateful callbacks, remove 
resource
                 scopeContainer.remove(contextId);



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to