[jboss-svn-commits] JBossWS SVN: r987 - branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/client

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Sep 19 01:37:34 EDT 2006


Author: thomas.diesler at jboss.com
Date: 2006-09-19 01:37:32 -0400 (Tue, 19 Sep 2006)
New Revision: 987

Modified:
   branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/client/PortProxy.java
Log:
partial commit

Modified: branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/client/PortProxy.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/client/PortProxy.java	2006-09-18 21:45:52 UTC (rev 986)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/client/PortProxy.java	2006-09-19 05:37:32 UTC (rev 987)
@@ -120,14 +120,20 @@
          {
             Object retObj;
             Class retType = method.getReturnType();
-            if (methodName.endsWith("Async"))
+            boolean isAsync = methodName.endsWith("Async");
+
+            // Invoke asynchronously
+            if (isAsync && JavaUtils.isAssignableFrom(Response.class, retType))
             {
-               if (JavaUtils.isAssignableFrom(Response.class, retType))
-               {
-                  
-               }
-               retObj = invoke(opName, args, retType);
+               retObj = invokeAsync(opName, args, retType);
             }
+            // Invoke asynchronously with handler
+            else if (isAsync && JavaUtils.isAssignableFrom(Future.class, retType) && args.length > 1)
+            {
+               Object handler = args[args.length - 1];
+               retObj = invokeAsync(opName, args, retType, (AsyncHandler)handler);
+            }
+            // Invoke synchronously
             else
             {
                retObj = invoke(opName, args, retType);
@@ -156,51 +162,62 @@
       return retObj;
    }
 
-   private void handleException(Exception ex) throws Throwable
+   private Response invokeAsync(QName opName, Object[] args, Class retType)
    {
-      Throwable th = ex;
-      throw th;
-   }
-
-   private Response invokeAsync(Object obj)
-   {
       ResponseImpl response = new ResponseImpl();
-      Runnable task = new AsyncRunnable(response, null, obj);
+      Runnable task = new AsyncRunnable(response, null, opName, args, retType);
       Future future = executor.submit(task);
       response.setFuture(future);
       return response;
    }
 
-   private Future invokeAsync(Object obj, AsyncHandler handler)
+   private Future invokeAsync(QName opName, Object[] args, Class retType, AsyncHandler handler)
    {
       ResponseImpl response = new ResponseImpl();
-      Runnable task = new AsyncRunnable(response, handler, obj);
+      Runnable task = new AsyncRunnable(response, handler, opName, args, retType);
       Future future = executor.submit(task);
       response.setFuture(future);
       return response;
    }
 
+   private void handleException(Exception ex) throws Throwable
+   {
+      Throwable th = ex;
+      throw th;
+   }
+
    class AsyncRunnable implements Runnable
    {
       private ResponseImpl response;
       private AsyncHandler handler;
-      private Object payload;
+      private QName opName;
+      private Object[] args;
+      private Class retType;
 
-      public AsyncRunnable(ResponseImpl response, AsyncHandler handler, Object payload)
+      public AsyncRunnable(ResponseImpl response, AsyncHandler handler, QName opName, Object[] args, Class retType)
       {
          this.response = response;
          this.handler = handler;
-         this.payload = payload;
+         this.opName = opName;
+         this.args = args;
+         this.retType = retType;
       }
 
       public void run()
       {
-         Object result = invoke(payload);
-         response.set(result);
-
-         // Call the handler if available
-         if (handler != null)
-            handler.handleResponse(response);
+         try
+         {
+            Object result = invoke(opName, args, retType);
+            response.set(result);
+            
+            // Call the handler if available
+            if (handler != null)
+               handler.handleResponse(response);
+         }
+         catch (RemoteException ex)
+         {
+            log.error("Asynchronous invokcation failed", ex);
+         }
       }
    }
 }




More information about the jboss-svn-commits mailing list