summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/core/src
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-01-21 15:39:42 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-01-21 15:39:42 +0000
commit2ea0eebe2f68ad06dc19abc7be2b6597ee80ed49 (patch)
treed00125252f5c701c8d8d682d4e314afa09fb75c6 /sca-java-2.x/trunk/modules/core/src
parent79e8d82441ee88da9ef1720d94ca8ccb573c306f (diff)
TUSCANY-3783 - Fix a hole in the AsyncReponseInvoker serialization to cover the case there invoker is de-serialized inside the same context that serialized it. Update the sample to demonstrate a stop/start scenario.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1061851 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/core/src')
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java1
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncResponseInvoker.java34
2 files changed, 34 insertions, 1 deletions
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
index e598be277a..0f86ee79ba 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
@@ -308,6 +308,7 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
} // end method invokeAsync(Operation, Message)
public void invokeAsyncResponse(Message msg){
+ resolve();
invoker.invokeAsyncResponse(msg);
}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncResponseInvoker.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncResponseInvoker.java
index 55c8d7fcab..38727d4670 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncResponseInvoker.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncResponseInvoker.java
@@ -19,11 +19,15 @@
package org.apache.tuscany.sca.core.invocation;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.context.CompositeContext;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
@@ -32,7 +36,11 @@ import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.InvokerAsyncResponse;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.node.NodeFactory;
import org.apache.tuscany.sca.provider.EndpointAsyncProvider;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
import org.oasisopen.sca.ComponentContext;
@@ -189,5 +197,29 @@ public class AsyncResponseInvoker<T> implements InvokerAsyncResponse, Serializab
public void setResponseEndpointReference(
RuntimeEndpointReference responseEndpointReference) {
this.responseEndpointReference = responseEndpointReference;
- }
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
+ {
+ in.defaultReadObject();
+
+ // find the real endpoint
+ ExtensionPointRegistry extensionPointRegistry = NodeFactory.getInstance().getExtensionPointRegistry();
+ DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(extensionPointRegistry);
+ Collection<EndpointRegistry> endpointRegistries = domainRegistryFactory.getEndpointRegistries();
+ EndpointRegistry endpointRegistry = endpointRegistries.iterator().next();
+ List<Endpoint> endpoints = endpointRegistry.findEndpoint(requestEndpoint.getURI());
+ requestEndpoint = (RuntimeEndpoint)endpoints.get(0);
+
+ if (responseTargetAddress instanceof EndpointReference){
+ // fix the target as in this case it will be an EPR
+ EndpointReference epr = (EndpointReference)responseTargetAddress;
+ List<EndpointReference> endpointReferences = endpointRegistry.getEndpointReferences();
+ for (EndpointReference endpointReference : endpointReferences){
+ if (endpointReference.getURI().equals(epr.getURI())){
+ responseTargetAddress = (T)endpointReference;
+ }
+ }
+ }
+ }
} // end class