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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Sep 18 17:45:55 EDT 2006


Author: thomas.diesler at jboss.com
Date: 2006-09-18 17:45:52 -0400 (Mon, 18 Sep 2006)
New Revision: 986

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

Modified: branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/client/ClientImpl.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/client/ClientImpl.java	2006-09-18 16:05:52 UTC (rev 985)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/client/ClientImpl.java	2006-09-18 21:45:52 UTC (rev 986)
@@ -111,6 +111,7 @@
       msgContext.setProperty(MessageContextJAXWS.MESSAGE_OUTBOUND_PROPERTY, new Boolean(true));
    }
    
+   // Invoked by the proxy invokation handler
    public Object invoke(QName opName, Object[] args) throws RemoteException
    {
       // Associate a message context with the current thread

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 16:05:52 UTC (rev 985)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/client/PortProxy.java	2006-09-18 21:45:52 UTC (rev 986)
@@ -25,13 +25,18 @@
 
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
+import java.rmi.RemoteException;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
 
 import javax.xml.namespace.QName;
+import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Response;
 
 import org.jboss.logging.Logger;
 import org.jboss.ws.WSException;
@@ -56,6 +61,8 @@
    private List stubMethods;
    // List<Method> of the Object methods
    private List objectMethods;
+   // The service configured executor
+   private ExecutorService executor;
 
    // The set of standard properties
    private static final Set<String> standardProperties = new HashSet<String>();
@@ -69,9 +76,10 @@
       standardProperties.add(BindingProvider.SOAPACTION_URI_PROPERTY);
    }
 
-   public PortProxy(ClientImpl client)
+   public PortProxy(ExecutorService executor, ClientImpl client)
    {
       this.client = client;
+      this.executor = executor;
       this.stubMethods = Arrays.asList(BindingProvider.class.getMethods());
       this.objectMethods = Arrays.asList(Object.class.getMethods());
    }
@@ -104,19 +112,26 @@
             throw new WSException("Cannot obtain operation meta data for: " + methodName);
 
          QName opName = opMetaData.getQName();
-         
+
+         if (log.isTraceEnabled())
+            log.trace("Invoke method: " + method + opMetaData);
+
          try
          {
-            Object retObj = client.invoke(opName, args);
-            if (retObj != null)
+            Object retObj;
+            Class retType = method.getReturnType();
+            if (methodName.endsWith("Async"))
             {
-               Class retType = method.getReturnType();
-               if (retType == null)
-                  throw new WSException("Return value not supported by: " + opMetaData);
-
-               if (JavaUtils.isPrimitive(retType))
-                  retObj = JavaUtils.getPrimitiveValue(retObj);
+               if (JavaUtils.isAssignableFrom(Response.class, retType))
+               {
+                  
+               }
+               retObj = invoke(opName, args, retType);
             }
+            else
+            {
+               retObj = invoke(opName, args, retType);
+            }
             return retObj;
          }
          catch (Exception ex)
@@ -127,9 +142,65 @@
       }
    }
 
+   private Object invoke(QName opName, Object[] args, Class retType) throws RemoteException
+   {
+      Object retObj = client.invoke(opName, args);
+      if (retObj != null)
+      {
+         if (retType == null)
+            throw new WSException("Return value not supported by: " + opName);
+
+         if (JavaUtils.isPrimitive(retType))
+            retObj = JavaUtils.getPrimitiveValue(retObj);
+      }
+      return retObj;
+   }
+
    private void handleException(Exception ex) throws Throwable
    {
       Throwable th = ex;
       throw th;
    }
+
+   private Response invokeAsync(Object obj)
+   {
+      ResponseImpl response = new ResponseImpl();
+      Runnable task = new AsyncRunnable(response, null, obj);
+      Future future = executor.submit(task);
+      response.setFuture(future);
+      return response;
+   }
+
+   private Future invokeAsync(Object obj, AsyncHandler handler)
+   {
+      ResponseImpl response = new ResponseImpl();
+      Runnable task = new AsyncRunnable(response, handler, obj);
+      Future future = executor.submit(task);
+      response.setFuture(future);
+      return response;
+   }
+
+   class AsyncRunnable implements Runnable
+   {
+      private ResponseImpl response;
+      private AsyncHandler handler;
+      private Object payload;
+
+      public AsyncRunnable(ResponseImpl response, AsyncHandler handler, Object payload)
+      {
+         this.response = response;
+         this.handler = handler;
+         this.payload = payload;
+      }
+
+      public void run()
+      {
+         Object result = invoke(payload);
+         response.set(result);
+
+         // Call the handler if available
+         if (handler != null)
+            handler.handleResponse(response);
+      }
+   }
 }

Modified: branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/spi/ServiceDelegateImpl.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/spi/ServiceDelegateImpl.java	2006-09-18 16:05:52 UTC (rev 985)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/spi/ServiceDelegateImpl.java	2006-09-18 21:45:52 UTC (rev 986)
@@ -286,7 +286,8 @@
             impl.initHandlerChain(epMetaData, HandlerType.POST);
          }
          
-         PortProxy handler = new PortProxy(new ClientImpl(epMetaData, handlerResolver));
+         ExecutorService executor = (ExecutorService)getExecutor();
+         PortProxy handler = new PortProxy(executor, new ClientImpl(epMetaData, handlerResolver));
          ClassLoader cl = epMetaData.getClassLoader();
          T proxy = (T)Proxy.newProxyInstance(cl, new Class[] { seiClass, BindingProvider.class }, handler);
          return proxy;




More information about the jboss-svn-commits mailing list