You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2011/11/21 12:23:31 UTC
svn commit: r1204448 - in
/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core:
assembly/impl/ invocation/ invocation/impl/
Author: antelder
Date: Mon Nov 21 11:23:30 2011
New Revision: 1204448
URL: http://svn.apache.org/viewvc?rev=1204448&view=rev
Log:
TUSCANY-3976: Apply patch from Greg Dritschler to allow extensions to save information about client async request
Added:
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncContext.java
Modified:
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKAsyncResponseInvoker.java
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncInvocationFutureImpl.java
Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java?rev=1204448&r1=1204447&r2=1204448&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java Mon Nov 21 11:23:30 2011
@@ -806,4 +806,18 @@ public class RuntimeEndpointReferenceImp
public void setDelegateEndpointReference(RuntimeEndpointReference delegateEndpointReference) {
this.delegateEndpointReference = delegateEndpointReference;
}
+
+ /**
+ * Gets the async response invoker for an asynchronous invocation.
+ */
+ public InvokerAsyncResponse getAsyncResponseInvoker(Operation op) {
+ InvocationChain chain = getInvocationChain(op);
+ Invoker headInvoker = chain.getHeadInvoker();
+ if( headInvoker instanceof InterceptorAsync ) {
+ InvokerAsyncResponse responseInvoker = ((InterceptorAsync)headInvoker).getPrevious();
+ return responseInvoker;
+ }
+ return null;
+ }
+
}
Added: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncContext.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncContext.java?rev=1204448&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncContext.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AsyncContext.java Mon Nov 21 11:23:30 2011
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core.invocation;
+
+/**
+ * Allows extensions to associate data with a client's async request.
+ */
+public interface AsyncContext {
+
+ /**
+ * Looks up an attribute value by name.
+ * @param name The name of the attribute
+ * @return The value of the attribute
+ */
+ public Object getAttribute(String name);
+
+ /**
+ * Sets the value of an attribute.
+ *
+ * @param name The name of the attribute
+ * @param value
+ */
+ public void setAttribute(String name, Object value);
+
+}
Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKAsyncResponseInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKAsyncResponseInvoker.java?rev=1204448&r1=1204447&r2=1204448&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKAsyncResponseInvoker.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKAsyncResponseInvoker.java Mon Nov 21 11:23:30 2011
@@ -30,4 +30,11 @@ public interface JDKAsyncResponseInvoker
*/
public void registerAsyncResponse( String id, Object responseHandler );
+ /**
+ * Returns the registered async response for a given ID
+ * @param id - the ID
+ * @return responseHandler - the response handler object
+ */
+ public Object getAsyncResponse( String id );
+
} // end interface JDKAsyncResponseInvoker
Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncInvocationFutureImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncInvocationFutureImpl.java?rev=1204448&r1=1204447&r2=1204448&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncInvocationFutureImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncInvocationFutureImpl.java Mon Nov 21 11:23:30 2011
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.core.invocation.impl;
+import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
@@ -32,6 +33,7 @@ import java.util.concurrent.locks.Reentr
import javax.xml.ws.AsyncHandler;
import javax.xml.ws.Response;
+import org.apache.tuscany.sca.core.invocation.AsyncContext;
import org.apache.tuscany.sca.core.invocation.AsyncFaultWrapper;
import org.apache.tuscany.sca.core.invocation.AsyncResponseHandler;
@@ -46,7 +48,7 @@ import org.apache.tuscany.sca.core.invoc
*
* @param <V> - this is the type of the response message from the invoked service.
*/
-public class AsyncInvocationFutureImpl<V> implements Future<V>, Response<V>, AsyncResponseHandler<V> {
+public class AsyncInvocationFutureImpl<V> implements Future<V>, Response<V>, AsyncContext, AsyncResponseHandler<V> {
// Lock for handling the completion of this Future
private final Lock lock = new ReentrantLock();
@@ -61,6 +63,8 @@ public class AsyncInvocationFutureImpl<V
private Class businessInterface = null;
private AsyncHandler callback;
+ private Map<String, Object> attributes = new HashMap<String, Object>();
+
protected AsyncInvocationFutureImpl() {
super();
} // end constructor
@@ -260,5 +264,22 @@ public class AsyncInvocationFutureImpl<V
this.callback = callback;
}
+ /**
+ * Look up an attribute value by name.
+ * @param name The name of the attribute
+ * @return The value of the attribute
+ */
+ public Object getAttribute(String name) {
+ return attributes.get(name);
+ }
+
+ /**
+ * Set the value of an attribute. Allows extensions to associate other data with an async response.
+ * @param name The name of the attribute
+ * @param value
+ */
+ public void setAttribute(String name, Object value) {
+ attributes.put(name, value);
+ }
} // end class AsyncInvocationFutureImpl