cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r449610 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/endpoint/ rt/core/src/main/java/org/apache/cxf/endpoint/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/
Date Mon, 25 Sep 2006 08:50:15 GMT
Author: ningjiang
Date: Mon Sep 25 01:50:14 2006
New Revision: 449610

URL: http://svn.apache.org/viewvc?view=rev&rev=449610
Log:
[JIRA CXF-108] 
Put the ReqestContext and ResponseContext to the context object keep the Client API clean

Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSAsyncCallable.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java?view=diff&rev=449610&r1=449609&r2=449610
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java Mon Sep 25 01:50:14
2006
@@ -25,19 +25,19 @@
 import org.apache.cxf.service.model.BindingOperationInfo;
 
 public interface Client extends InterceptorProvider {
+    String REQUEST_CONTEXT = "RequestContext";
+    String RESPONSE_CONTEXT = "ResponseContext";
     
     /**
      * Invokes an operation syncronously
      * @param oi  The operation to be invoked
      * @param params  The params that matches the parts of the input message of the operation
-     * @param requestContext  Optional (can be null) request contextual information for the
invocation
-     * @param responseContext Optional (can be null) response contextual information for
the invocation
+     * @param context  Optional (can be null) contextual information for the invocation 
   
      * @return The return values that matche the parts of the output message of the operation
      */
     Object[] invoke(BindingOperationInfo oi,
                     Object[] params,
-                    Map<String, Object> requestContext,
-                    Map<String, Object> responseContext);
+                    Map<String, Object> context);
 
     Endpoint getEndpoint();
    

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java?view=diff&rev=449610&r1=449609&r2=449610
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java Mon
Sep 25 01:50:14 2006
@@ -73,13 +73,20 @@
     }
 
         
+    
+    @SuppressWarnings("unchecked")
     public Object[] invoke(BindingOperationInfo oi, Object[] params, 
-                           Map<String, Object> requestContext, Map<String, Object>
responseContext) {
+                           Map<String, Object> context) {
+        Map<String, Object> requestContext = null;
+        Map<String, Object> responseContext = null;
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("Invoke, operation info: " + oi + ", params: " + params);
         }
         Message message = endpoint.getBinding().createMessage();
-        
+        if (null != context) {
+            requestContext = (Map<String, Object>) context.get(REQUEST_CONTEXT);
+            responseContext = (Map<String, Object>) context.get(RESPONSE_CONTEXT);
+        }    
         //setup the message context
         setContext(requestContext, message);
         //setMethod(ctx, message);

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java?view=diff&rev=449610&r1=449609&r2=449610
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
Mon Sep 25 01:50:14 2006
@@ -24,6 +24,7 @@
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.FutureTask;
@@ -82,14 +83,17 @@
         Object[] paramsWithOutHolder = handleHolder(params);
         Map<String, Object> requestContext = this.getRequestContext();
         Map<String, Object> responseContext = this.getResponseContext();
+        Map<String, Object> context = new HashMap<String, Object>();
+        context.put(Client.REQUEST_CONTEXT, requestContext);
+        context.put(Client.RESPONSE_CONTEXT, responseContext);
 
         requestContext.put(Method.class.getName(), method);
 
         boolean isAsync = method.getName().endsWith("Async");
         if (isAsync) {
-            return invokeAsync(method, oi, params, paramsWithOutHolder, requestContext, responseContext);
+            return invokeAsync(method, oi, params, paramsWithOutHolder, context);
         } else {
-            return invokeSync(method, oi, params, paramsWithOutHolder, requestContext, responseContext);
+            return invokeSync(method, oi, params, paramsWithOutHolder, context);
         }
     }
 
@@ -98,9 +102,8 @@
                           BindingOperationInfo oi, 
                           Object[] params, 
                           Object[] paramsWithOutHolder, 
-                          Map<String, Object> requestContext,
-                          Map<String, Object> responseContext) {
-        Object rawRet[] = client.invoke(oi, paramsWithOutHolder, requestContext, responseContext);
+                          Map<String, Object> context) {
+        Object rawRet[] = client.invoke(oi, paramsWithOutHolder, context);
 
         if (rawRet != null && rawRet.length != 0) {
             List<Object> retList = new ArrayList<Object>();
@@ -116,16 +119,14 @@
                                BindingOperationInfo oi, 
                                Object[] params, 
                                Object[] paramsWithOutHolder, 
-                               Map<String, Object> requestContext,
-                               Map<String, Object> responseContext) {
+                               Map<String, Object> context) {
         
         FutureTask<Object> f = new FutureTask<Object>(new JAXWSAsyncCallable(this,

                                                                              method,
                                                                              oi,
                                                                              params,
                                                                              paramsWithOutHolder,
-                                                                             requestContext,
-                                                                             responseContext
+                                                                             context
                                                                              ));
 
         endpoint.getService().getExecutor().execute(f);

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSAsyncCallable.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSAsyncCallable.java?view=diff&rev=449610&r1=449609&r2=449610
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSAsyncCallable.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSAsyncCallable.java
Mon Sep 25 01:50:14 2006
@@ -32,23 +32,20 @@
     private BindingOperationInfo oi; 
     private Object[] params;
     private Object[] paramsWithOutHolder; 
-    private Map<String, Object> requestContext;
-    private Map<String, Object> responseContext;
+    private Map<String, Object> context;
     
     public JAXWSAsyncCallable(EndpointInvocationHandler endPointInvocationHandler,
                               Method method,
                               BindingOperationInfo oi,
                               Object[] params,
                               Object[] paramsWithOutHolder,
-                              Map<String, Object> reqCxt,
-                              Map<String, Object> respCxt) {
+                              Map<String, Object> cxt) {
         this.endPointInvocationHandler = endPointInvocationHandler;
         this.method = method;
         this.oi = oi;
         this.params = params;
         this.paramsWithOutHolder = paramsWithOutHolder;
-        this.requestContext = reqCxt;
-        this.responseContext = respCxt;
+        this.context = cxt;        
     }
     
     public Object call() throws Exception {
@@ -56,8 +53,7 @@
                                                 oi, 
                                                 params, 
                                                 paramsWithOutHolder,
-                                                requestContext,
-                                                responseContext);
+                                                context);
     }
 
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java?view=diff&rev=449610&r1=449609&r2=449610
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
Mon Sep 25 01:50:14 2006
@@ -123,7 +123,7 @@
         assertNotNull(bop);
         bop = bop.getUnwrappedOperation();
         assertNotNull(bop);
-        Object ret[] = client.invoke(bop, new Object[0], null, null);
+        Object ret[] = client.invoke(bop, new Object[0], null);
         assertNotNull(ret);
         assertEquals("Wrong number of return objects", 1, ret.length);
     }



Mime
View raw message