From 0d84cc78489ac547b2bacec57286a33a06dfcab3 Mon Sep 17 00:00:00 2001 From: edwardsmj Date: Mon, 24 Jan 2011 20:02:06 +0000 Subject: Fixing serialization of AsyncResponseInvoker in support of async services under TUSCANY-3783 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1062950 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/core/invocation/AsyncResponseInvoker.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) 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 2e675c5e7a..da1c7f365e 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 @@ -70,7 +70,7 @@ public class AsyncResponseInvoker implements InvokerAsyncResponse, Serializab private T responseTargetAddress; private String relatesToMsgID; private String operationName; - private MessageFactory messageFactory; + private transient MessageFactory messageFactory; private String bindingType = ""; private boolean isNativeAsync; @@ -79,6 +79,7 @@ public class AsyncResponseInvoker implements InvokerAsyncResponse, Serializab private String domainURI; private transient EndpointRegistry endpointRegistry; + private transient ExtensionPointRegistry registry; public AsyncResponseInvoker(RuntimeEndpoint requestEndpoint, RuntimeEndpointReference responseEndpointReference, @@ -104,6 +105,7 @@ public class AsyncResponseInvoker implements InvokerAsyncResponse, Serializab if( context != null ) { domainURI = context.getDomainURI(); + registry = context.getExtensionPointRegistry(); } // end if if ((requestEndpoint.getBindingProvider() instanceof EndpointAsyncProvider) && @@ -237,6 +239,8 @@ public class AsyncResponseInvoker implements InvokerAsyncResponse, Serializab requestEndpoint = retrieveEndpoint(endpointURI); responseEndpointReference = retrieveEndpointReference(endpointReferenceURI); + messageFactory = getMessageFactory(); + if (responseTargetAddress instanceof EndpointReference){ // fix the target as in this case it will be an EPR EndpointReference epr = (EndpointReference)responseTargetAddress; @@ -245,6 +249,14 @@ public class AsyncResponseInvoker implements InvokerAsyncResponse, Serializab } // end method readObject /** + * Gets a message factory + * @return + */ + private MessageFactory getMessageFactory() { + return registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(MessageFactory.class); + } // end method getMessageFactory + + /** * Fetches the EndpointReference identified by an endpoint reference URI * @param uri - the URI of the endpoint reference * @return - the EndpointReference matching the supplied URI - null if no EPR is found which @@ -290,7 +302,10 @@ public class AsyncResponseInvoker implements InvokerAsyncResponse, Serializab if( context != null ) { registry = context.getExtensionPointRegistry(); endpointRegistry = getEndpointRegistry( registry ); - if( endpointRegistry != null ) return endpointRegistry; + if( endpointRegistry != null ) { + this.registry = registry; + return endpointRegistry; + } // end if } // end if // Deal with the case where there is no context available @@ -303,6 +318,7 @@ public class AsyncResponseInvoker implements InvokerAsyncResponse, Serializab if( endpointRegistry != null ) { for( Endpoint endpoint : endpointRegistry.findEndpoint(uri) ) { // TODO: For the present, simply return the first registry with a matching endpoint + this.registry = registry; return endpointRegistry; } // end for } // end if -- cgit v1.2.3