You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ng...@apache.org on 2007/02/14 03:13:51 UTC

svn commit: r507358 [1/2] - in /webservices/axis2/trunk/java/modules: jaxws/src/org/apache/axis2/jaxws/client/async/ jaxws/src/org/apache/axis2/jaxws/client/proxy/ jaxws/src/org/apache/axis2/jaxws/core/controller/ jaxws/test/org/apache/axis2/jaxws/samp...

Author: ngallardo
Date: Tue Feb 13 18:13:51 2007
New Revision: 507358

URL: http://svn.apache.org/viewvc?view=rev&rev=507358
Log:
AXIS2-2170
Contributor: Ann Robinson

Ann's fix for some Executor issues.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/ParallelAsyncTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/parallelasync/server/AsyncPort.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/parallelasync/server/DocLitWrappedPortImpl.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/parallelasync/server/META-INF/async_doclitwr.wsdl
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java?view=diff&rev=507358&r1=507357&r2=507358
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java Tue Feb 13 18:13:51 2007
@@ -132,15 +132,32 @@
         if (log.isDebugEnabled()) {
             log.debug("Executor task starting to process async response");
         }
-        
+
         if (executor != null) {
         	if(task!=null && !task.isCancelled()){
-        		executor.execute(task);
+                try {
+                    executor.execute(task);
+                }
+                catch (Exception executorExc) {
+                    if(log.isDebugEnabled()){
+                        log.debug("CallbackFuture.execute():  executor exception ["+executorExc.getClass().getName()+"]");
+                    }
+
+                    // attempt to cancel the FutureTask
+                    task.cancel(true);
+
+                    //   note: if it is becomes required to return the actual exception
+                    //         to the client, then we would need to doing something
+                    //         similar to setting the CallbackFutureTask with the error
+                    //         and invoking the CallbackFutureTask.call() interface
+                    //         to process the information
+                    //
+                }
+
         		if(log.isDebugEnabled()){
         			log.debug("Task submitted to Executor");
         		}
         	}else{
-        		System.out.println("Task is cancelled");
         		if(log.isDebugEnabled()){
         			log.info("Executor task was not sumbitted as Async Future task was cancelled by clients");
         		}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java?view=diff&rev=507358&r1=507357&r2=507358
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java Tue Feb 13 18:13:51 2007
@@ -21,6 +21,7 @@
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 
 import javax.xml.ws.AsyncHandler;
@@ -171,7 +172,7 @@
         //if (action != null && requestContext.get(BindingProvider.SOAPACTION_URI_PROPERTY) == null) {
         //    getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, action);
         //}
-        
+                 
         // Before we invoke, copy all of the properties from the client request
         // context to the MessageContext
         request.getProperties().putAll(getRequestContext());
@@ -209,10 +210,22 @@
 				}
 			}
 			if(asyncHandler == null){
-				throw ExceptionFactory.makeWebServiceException("AynchHandler null for Async callback, Invalid AsyncHandler callback Object");
+				throw ExceptionFactory.makeWebServiceException("AsynchHandler null for Async callback, Invalid AsyncHandler callback Object");
 			}
 			AsyncResponse listener = createProxyListener(args, operationDesc);
 			requestIC.setAsyncResponseListener(listener);
+
+	        if ((serviceDelegate.getExecutor()!= null) && (serviceDelegate.getExecutor() instanceof ExecutorService))
+	        {
+	            ExecutorService es = (ExecutorService) serviceDelegate.getExecutor();
+	            if (es.isShutdown())
+	            {
+	                // the executor service is shutdown and won't accept new tasks
+	                // so return an error back to the client
+	                throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ExecutorShutdown"));
+	            }
+	        }
+
 			requestIC.setExecutor(serviceDelegate.getExecutor());
 				        
 	        Future<?> future = controller.invokeAsync(requestIC, asyncHandler);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java?view=diff&rev=507358&r1=507357&r2=507358
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java Tue Feb 13 18:13:51 2007
@@ -16,6 +16,7 @@
  */
 package org.apache.axis2.jaxws.core.controller;
 
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 
 import javax.xml.ws.AsyncHandler;
@@ -197,7 +198,17 @@
         if (ic.getRequestMessageContext() == null) {
             throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
         }
-        
+        if ((ic.getExecutor() != null) && (ic.getExecutor() instanceof ExecutorService))
+        {
+            ExecutorService es = (ExecutorService) ic.getExecutor();
+            if (es.isShutdown())
+            {
+                // the executor service is shutdown and won't accept new tasks
+                // so return an error back to the client
+                throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ExecutorShutdown"));
+            }
+        }
+
         MessageContext request = ic.getRequestMessageContext();
         request.getProperties().put(Constants.INVOCATION_PATTERN, InvocationPattern.ASYNC_CALLBACK);
         

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/ParallelAsyncTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/ParallelAsyncTests.java?view=diff&rev=507358&r1=507357&r2=507358
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/ParallelAsyncTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/ParallelAsyncTests.java Tue Feb 13 18:13:51 2007
@@ -1,155 +1,547 @@
-package org.apache.axis2.jaxws.sample;
-
-import java.util.Map;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Future;
-
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Response;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.axis2.jaxws.sample.parallelasync.server.AsyncPort;
-import org.apache.axis2.jaxws.sample.parallelasync.server.AsyncService;
-import org.apache.log4j.BasicConfigurator;
-import org.test.parallelasync.CustomAsyncResponse;
-import org.test.parallelasync.SleepResponse;
-
-/**
- * Tests for Asynchrony in JAX-WS. Most of the simple invokeAsync/async
- * exceptions have been covered under jaxws.dispatch and jaxws.proxy test suites
- * 
- * ExecutionException tests are covered in jaxws.dispatch and jaxws.proxy
- */
-public class ParallelAsyncTests extends TestCase {
-
-    private static final String DOCLITWR_ASYNC_ENDPOINT =
-        "http://localhost:8080/axis2/services/AsyncService";
-
-
-    public ParallelAsyncTests(String str) {
-        super(str);
-    }
-
-    public static Test suite() {
-        TestSuite suite = new TestSuite(ParallelAsyncTests.class);
-        return suite;
-        
-    }
-
-    public void setUp() {
-        System.out.println("==================== " + getName());
-    }
-    
-    public void testNOOP () {}
-    /**
-     * @testStrategy Test that the service is up and running before running any
-     *               other tests
-     * @wsdl async.wsdl + async.xml
-     * @target AsyncPortImpl
-     */
-    public void testService_isAlive() throws Exception {
-        final String MESSAGE = "testServiceAlive";
-
-        AsyncPort port = getPort(null);
-
-        String req1 = "sleepAsync";
-        String req2 = "remappedAsync";
-
-        for (int i = 0; i < 10; i++) {
-            
-            Response<SleepResponse> resp1 = port.sleepAsync(req1);
-            Response<CustomAsyncResponse> resp2 = port.remappedAsync(req2);
-
-            waitBlocking(resp2);
-            port.wakeUp();
-
-            waitBlocking(resp1);
-        
-            String req1_result = null;
-            String req2_result = null;
-            try {
-                req1_result = resp1.get().getMessage();
-                req2_result = resp2.get().getResponse();
-            } catch (Exception e) {
-                e.printStackTrace();
-                fail(e.toString());
-            }
-
-            assertEquals("sleepAsync did not return expected response ", req1, req1_result);
-            assertEquals("remappedAsync did not return expected response", req2, req2_result);
-            
-            // Calling get() again should return the same object as the first call to get()
-            assertEquals("sleepAsync did not return expected response ", req1, resp1.get().getMessage());
-            assertEquals("remappedAsync did not return expected response", req2, resp2.get().getResponse());
-            
-            // Change the request for the next time through the loop
-            req1 = req1+"!";
-            req2 = req2+"!";
-        }
-        
-    }
-
-    /**
-     * Auxiliary method used for doiing isAsleep checks. Will perform isAsleep
-     * up to a MAX_ISASLEEP_CHECK number of checks. Will sleep for
-     * SLEEP_ISASLEEP_SEC seconds in between requests. If reaches maximum number
-     * fo retries then will fail the test
-     */
-    private boolean isAsleepCheck(String MESSAGE, AsyncPort port) {
-        boolean asleep = false;
-        int check = 30;
-        String msg = null;
-        do {
-            msg = port.isAsleep();
-            asleep = (msg != null);
-
-            // fail the test if we ran out of checks
-            if ((check--) == 0)
-                fail("Serve did not receive sleep after several retries");
-
-            // sleep for a bit
-            try {
-                Thread.sleep(30);
-            } catch (InterruptedException e) {
-            }
-
-        } while (!asleep);
-
-        if (asleep) {
-            assertTrue("Sleeping on an incorrect message", MESSAGE.equals(msg));
-        }
-
-        return true;
-    }
-    
-    /**
-     * Auxiliary method used for obtaining a proxy pre-configured with a
-     * specific Executor
-     */
-    private AsyncPort getPort(Executor ex) {
-        AsyncService service = new AsyncService();
-
-        if (ex!= null)
-            service.setExecutor(ex);
-        
-        AsyncPort port = service.getAsyncPort();
-        assertNotNull("Port is null", port);
-
-        Map<String, Object> rc = ((BindingProvider) port).getRequestContext();
-        rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
-                DOCLITWR_ASYNC_ENDPOINT);
-        
-        return port;
-    }
-    
-    private void waitBlocking(Future<?> monitor){
-        while (!monitor.isDone()){
-            try {
-                Thread.sleep(1000);
-            } catch (InterruptedException e) {
-            }
-        }
-    }
-}
+package org.apache.axis2.jaxws.sample;
+
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.RejectedExecutionException;
+
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Response;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.axis2.jaxws.sample.parallelasync.common.CallbackHandler;
+import org.apache.axis2.jaxws.sample.parallelasync.server.AsyncPort;
+import org.apache.axis2.jaxws.sample.parallelasync.server.AsyncService;
+import org.apache.log4j.BasicConfigurator;
+import org.test.parallelasync.CustomAsyncResponse;
+import org.test.parallelasync.SleepResponse;
+import org.test.parallelasync.WakeUpResponse;
+
+/**
+ * Tests for Asynchrony in JAX-WS. Most of the simple invokeAsync/async
+ * exceptions have been covered under jaxws.dispatch and jaxws.proxy test suites
+ * 
+ * ExecutionException tests are covered in jaxws.dispatch and jaxws.proxy
+ */
+public class ParallelAsyncTests extends TestCase {
+
+    private static final String DOCLITWR_ASYNC_ENDPOINT =
+        "http://localhost:8080/axis2/services/AsyncService";
+
+    // used for logging
+    private String myClassName = "ParallelAsyncTests";
+
+    public ParallelAsyncTests(String str) {
+        super(str);
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite(ParallelAsyncTests.class);
+        return suite;
+        
+    }
+
+    public void setUp() {
+        System.out.println("==================== " + getName());
+    }
+    
+    public void testNOOP () {}
+
+    /**
+     * @testStrategy Check that the web service is up and running 
+     *               before running any other tests
+     */
+    public void testService_isAlive() throws Exception {
+        final String MESSAGE = "testServiceAlive";
+
+        String title = myClassName + " : " + getName() + " : ";
+
+        AsyncPort port = getPort((Executor)null);
+
+        String req1base = "sleepAsync";
+        String req2base = "remappedAsync";
+
+        String request1 = null;
+        String request2 = null;
+
+        for (int i = 0; i < 10; i++) {
+            
+            request1 = req1base + "_" + i;
+            request2 = req2base + "_" + i;
+
+            System.out.println(title+"iteration ["+i+"] using request1 ["+request1+"]  request2 ["+request2+"]");
+
+            // submit request #1 to the server-side web service that 
+            // the web service will keep until we ask for it
+            Response<SleepResponse> resp1 = port.sleepAsync(request1);
+
+            // submit request #2 to the server that essentially processes
+            // without delay
+            Response<CustomAsyncResponse> resp2 = port.remappedAsync(request2);
+
+            // wait until the response for request #2 is done 
+            waitBlocking(resp2);
+
+            // check the waiting request #1
+            String asleep = port.isAsleep(request1);
+            //System.out.println(title+"iteration ["+i+"]   port.isAsleep(request1 ["+request1+"]) = ["+asleep+"]");
+
+            // wakeup the waiting request #1
+            String wake = port.wakeUp(request1);
+            //System.out.println(title+"iteration ["+i+"]   port.wakeUp(request1 ["+request1+"]) = ["+wake+"]");
+
+            // wait until the response for request #1 is done
+            waitBlocking(resp1);
+        
+            // get the responses
+            String req1_result = null;
+            String req2_result = null;
+
+            try {
+                req1_result = resp1.get().getMessage();
+                req2_result = resp2.get().getResponse();
+            } catch (Exception e) {
+                System.out.println(title+"iteration ["+i+"] using request1 ["+request1+"]  request2 ["+request2+"] :  got exception ["+e.getClass().getName()+"]  ["+e.getMessage()+"] ");
+                e.printStackTrace();
+                fail(e.toString());
+            }
+
+            // check status on request #1
+            assertEquals("sleepAsync did not sleep as expected", request1, asleep);
+            assertEquals("sleepAsync did not return expected response ", request1, req1_result);
+
+            // check status on request #2
+            assertEquals("remappedAsync did not return expected response", request2, req2_result);
+            
+
+            // Calling get() again should return the same object as the first call to get()
+            assertEquals("sleepAsync did not return expected response ", request1, resp1.get().getMessage());
+            assertEquals("remappedAsync did not return expected response", request2, resp2.get().getResponse());
+            
+        }
+        
+        // check the callback operation
+		CallbackHandler<SleepResponse> sleepCallbackHandler = new CallbackHandler<SleepResponse>();
+
+        request1 = req1base + "_with_Callback";
+        //System.out.println(title+" port.sleepAsync("+request1+", callbackHander)  being submitted....");
+		Future<?> sr = port.sleepAsync(request1, sleepCallbackHandler);
+
+        // wait a bit for the server to process the request ...
+        Thread.sleep(500);
+
+        // check the waiting request 
+        String asleepWithCallback = port.isAsleep(request1);
+        //System.out.println(title+" port.isAsleep("+request1+") = ["+asleepWithCallback+"]");
+
+        // wakeup the waiting request
+        String wake = port.wakeUp(request1);
+        //System.out.println(title+" port.wakeUp("+request1+") = ["+wake+"]");
+
+        // wait a bit..
+        Thread.sleep(500);
+
+        // get the response
+        String req_cb_result = null;
+
+        try {
+
+            SleepResponse sleepResp = sleepCallbackHandler.get();
+
+            if (sleepResp != null)
+            {
+                req_cb_result = sleepResp.getMessage();
+                System.out.println(title+" request ["+request1+"] :  result ["+req_cb_result+"] ");
+            }
+
+        } catch (Exception ex) {
+            System.out.println(title+" request ["+request1+"] :  got exception ["+ex.getClass().getName()+"]  ["+ex.getMessage()+"] ");
+            ex.printStackTrace();
+            fail(ex.toString());
+        }
+
+        // check status on request
+        assertEquals("sleepAsync with callback did not sleep as expected", request1, req_cb_result);
+
+    }
+
+
+    /**
+     * @testStrategy Test for ordering an executor to shutdownNow while there
+     *               is a request being processed.  Uses the default executor.
+     *               
+     */
+    public void testService_ExecutorShutdownNow() throws Exception {
+        final String MESSAGE = "testExecutorShutdownNow";
+
+        String title = myClassName + " : " + getName() + " : ";
+
+        AsyncService service = getService(null);
+        AsyncPort port = getPort(service);
+
+		// get the default executor and check to make sure it is an executor service
+        ExecutorService ex = null;
+        Executor executor = service.getExecutor();
+        if ((executor != null) && (executor instanceof ExecutorService))
+        {
+            ex = (ExecutorService) executor;
+        }
+        else
+        {
+            System.out.println(title+" No executor service available. Nothing to test.");
+            return;
+        }
+
+
+        // submit a request to the server that will wait until we ask for it
+		CallbackHandler<SleepResponse> sleepCallbackHandler1 = new CallbackHandler<SleepResponse>();
+
+        String request1 = "sleepAsync_with_Callback_1";
+
+        System.out.println(title+" port.sleepAsync("+request1+", callbackHander1)  #1 being submitted....");
+		Future<?> sr1 = port.sleepAsync(request1, sleepCallbackHandler1);
+        System.out.println(title+" port.sleepAsync("+request1+", callbackHander1)  #1 .....submitted.");
+
+        // wait a bit to make sure that the server has the request
+        Thread.sleep(1000);
+
+		// tell the executor to shutdown immediately, which 
+        // attempts to stop all actively executing tasks via Thread.interrupt()
+        // and should prevent new tasks from being submitted
+        System.out.println(title+" shutting down executor ["+ex.getClass().getName()+"]");
+        ex.shutdownNow();
+
+        // check the waiting request 
+        System.out.println(title+" port.isAsleep("+request1+") #1 being submitted....");
+        String asleepWithCallback1 = port.isAsleep(request1);
+        System.out.println(title+" port.isAsleep("+request1+") #1 = ["+asleepWithCallback1+"]");
+
+        // wakeup the waiting request
+        System.out.println(title+" port.wakeUp(request1) #1 being submitted....");
+        String wake1 = port.wakeUp(request1);
+        System.out.println(title+" port.wakeUp("+request1+") #1 = ["+wake1+"]");
+
+        // wait a bit..
+        Thread.sleep(2000);
+
+        // check the Future
+        if (sr1.isDone())
+        {
+            System.out.println(title+" sr1.isDone[TRUE] ");
+        }
+
+        // try to get the response
+        boolean gotException = false;
+        try {
+
+            SleepResponse sleepResp1 = sleepCallbackHandler1.get();
+
+            if (sleepResp1 != null)
+            {
+                System.out.println(title+" request ["+request1+"] #1:  sleepResponse [NOT NULL] from callback handler");
+                String result1 = sleepResp1.getMessage();
+                System.out.println(title+" request ["+request1+"] #1:  result ["+result1+"] ");
+            }
+            else
+            {
+                System.out.println(title+" request ["+request1+"] #1:  sleepResponse [NULL] from callback handler");
+
+                // see what the Future says
+                System.out.println(title+" request ["+request1+"] #1:  ....check Future response...");
+                Object futureResult = sr1.get();
+                System.out.println(title+" request ["+request1+"] #1:  ....Future response ["+futureResult+"]...");
+            }
+
+        } catch (Exception exc) {
+
+            System.out.println(title+" request ["+request1+"] :  got exception ["+exc.getClass().getName()+"]  ["+exc.getMessage()+"] ");
+            gotException = true;
+        }
+
+        assertTrue("Did not receive an exception from trying to access the response when the executor service is shutdown.",gotException);
+    }
+
+
+    /**
+     * @testStrategy Test for ordering an executor to shutdownNow while there
+     *               is a request being processed.  Uses an application executor
+     *               service.
+     */
+    public void testService_ExecutorShutdownNow_2() throws Exception {
+        final String MESSAGE = "testExecutorShutdownNow_2";
+
+        String title = myClassName + " : " + getName() + " : ";
+
+        AsyncService service = getService(null);
+        AsyncPort port = getPort(service);
+
+		// get the default executor and check to make sure it is an executor service
+		ExecutorService ex = Executors.newSingleThreadExecutor();
+		service.setExecutor(ex);
+
+
+        // submit a request to the server that will wait until we ask for it
+		CallbackHandler<SleepResponse> sleepCallbackHandler1 = new CallbackHandler<SleepResponse>();
+
+        String request1 = "sleepAsync_with_Callback_1";
+
+        System.out.println(title+" port.sleepAsync("+request1+", callbackHander1)  #1 being submitted....");
+		Future<?> sr1 = port.sleepAsync(request1, sleepCallbackHandler1);
+        System.out.println(title+" port.sleepAsync("+request1+", callbackHander1)  #1 .....submitted.");
+
+        // wait a bit to make sure that the server has the request
+        Thread.sleep(1000);
+
+		// tell the executor to shutdown immediately, which 
+        // attempts to stop all actively executing tasks via Thread.interrupt()
+        // and should prevent new tasks from being submitted
+        System.out.println(title+" shutting down executor ["+ex.getClass().getName()+"]");
+        ex.shutdownNow();
+
+        // check the waiting request 
+        System.out.println(title+" port.isAsleep("+request1+") #1 being submitted....");
+        String asleepWithCallback1 = port.isAsleep(request1);
+        System.out.println(title+" port.isAsleep("+request1+") #1 = ["+asleepWithCallback1+"]");
+
+        // wakeup the waiting request
+        System.out.println(title+" port.wakeUp(request1) #1 being submitted....");
+        String wake1 = port.wakeUp(request1);
+        System.out.println(title+" port.wakeUp("+request1+") #1 = ["+wake1+"]");
+
+        // wait a bit..
+        Thread.sleep(2000);
+
+        // check the Future
+        if (sr1.isDone())
+        {
+            System.out.println(title+" sr1.isDone[TRUE] ");
+        }
+
+        // try to get the response
+        boolean gotException = false;
+        try {
+
+            SleepResponse sleepResp1 = sleepCallbackHandler1.get();
+
+            if (sleepResp1 != null)
+            {
+                System.out.println(title+" request ["+request1+"] #1:  sleepResponse [NOT NULL] from callback handler");
+                String result1 = sleepResp1.getMessage();
+                System.out.println(title+" request ["+request1+"] #1:  result ["+result1+"] ");
+            }
+            else
+            {
+                System.out.println(title+" request ["+request1+"] #1:  sleepResponse [NULL] from callback handler");
+
+                // see what the Future says
+                System.out.println(title+" request ["+request1+"] #1:  ....check Future response...");
+                Object futureResult = sr1.get();
+                System.out.println(title+" request ["+request1+"] #1:  ....Future response ["+futureResult+"]...");
+            }
+
+        } catch (Exception exc) {
+
+            System.out.println(title+" request ["+request1+"] :  got exception ["+exc.getClass().getName()+"]  ["+exc.getMessage()+"] ");
+            gotException = true;
+        }
+
+        assertTrue("Did not receive an exception from trying to access the response when the executor service is shutdown.",gotException);
+    }
+
+    /**
+     * @testStrategy Test for ordering an executor to shutdownNow before there
+     *               is a request.  Uses the default executor.
+     *               
+     */
+    public void testService_ExecutorShutdownNow_3() throws Exception {
+        final String MESSAGE = "testExecutorShutdownNow_3";
+
+        String title = myClassName + " : " + getName() + " : ";
+
+        AsyncService service = getService(null);
+        AsyncPort port = getPort(service);
+
+		// get the default executor and check to make sure it is an executor service
+        ExecutorService ex = null;
+        Executor executor = service.getExecutor();
+        if ((executor != null) && (executor instanceof ExecutorService))
+        {
+            ex = (ExecutorService) executor;
+
+            // tell the executor to shutdown immediately, which 
+            // attempts to stop all actively executing tasks via Thread.interrupt()
+            // and should prevent new tasks from being submitted
+            System.out.println(title+" shutting down executor ["+ex.getClass().getName()+"]");
+            ex.shutdownNow();
+        }
+        else
+        {
+            System.out.println(title+" No executor service available. Nothing to test.");
+            return;
+        }
+
+
+        boolean gotRequestException = false;
+
+        String request1 = "sleepAsync_with_Callback_1";
+        CallbackHandler<SleepResponse> sleepCallbackHandler1 = new CallbackHandler<SleepResponse>();
+        Future<?> sr1 = null;
+
+        try
+        {
+            // submit a request to the server that will wait until we ask for it
+            System.out.println(title+" port.sleepAsync("+request1+", callbackHander1)  #1 being submitted....");
+            sr1 = port.sleepAsync(request1, sleepCallbackHandler1);
+            System.out.println(title+" port.sleepAsync("+request1+", callbackHander1)  #1 .....submitted.");
+        }
+        catch (Exception exc)
+        {
+            System.out.println(title+" request ["+request1+"] :  got exception ["+exc.getClass().getName()+"]  ["+exc.getMessage()+"] ");
+            gotRequestException = true;
+        }
+
+        // if the request went through, continue processing to see if the response is stopped
+        // this makes sure that the server doesn't keep the request forever
+        boolean gotResponseException = false;
+
+        if (!gotRequestException)
+        {
+            // wakeup the waiting request
+            System.out.println(title+" port.wakeUp(request1) #1 being submitted....");
+            String wake1 = port.wakeUp(request1);
+            System.out.println(title+" port.wakeUp("+request1+") #1 = ["+wake1+"]");
+
+            // try to get the response
+            try {
+
+                SleepResponse sleepResp1 = sleepCallbackHandler1.get();
+
+                if (sleepResp1 != null)
+                {
+                    System.out.println(title+" request ["+request1+"] #1:  sleepResponse [NOT NULL] from callback handler");
+                    String result1 = sleepResp1.getMessage();
+                    System.out.println(title+" request ["+request1+"] #1:  result ["+result1+"] ");
+                }
+                else
+                {
+                    System.out.println(title+" request ["+request1+"] #1:  sleepResponse [NULL] from callback handler");
+
+                    // see what the Future says
+                    System.out.println(title+" request ["+request1+"] #1:  ....check Future response...");
+                    Object futureResult = sr1.get();
+                    System.out.println(title+" request ["+request1+"] #1:  ....Future response ["+futureResult+"]...");
+                }
+
+            } catch (Exception exc) {
+
+                System.out.println(title+" request ["+request1+"] :  got exception ["+exc.getClass().getName()+"]  ["+exc.getMessage()+"] ");
+                gotResponseException = true;
+            }
+        }
+
+        assertTrue("Did not receive an exception from trying to submit the request when the executor service is shutdown.",gotRequestException);
+
+        //assertTrue("Did not receive an exception from trying to access the response when the executor service is shutdown.",gotResponseException);
+    }
+
+
+
+
+    /**
+     * Auxiliary method used for doing isAsleep checks. Will perform isAsleep
+     * up to a MAX_ISASLEEP_CHECK number of checks. Will sleep for
+     * SLEEP_ISASLEEP_SEC seconds in between requests. If reaches maximum number
+     * fo retries then will fail the test
+     */
+    private boolean isAsleepCheck(String MESSAGE, AsyncPort port) {
+        boolean asleep = false;
+        int check = 30;
+        String msg = null;
+        do {
+            msg = port.isAsleep(MESSAGE);
+            asleep = (msg != null);
+
+            // fail the test if we ran out of checks
+            if ((check--) == 0)
+                fail("Serve did not receive sleep after several retries");
+
+            // sleep for a bit
+            try {
+                Thread.sleep(30);
+            } 
+            catch (InterruptedException e) {
+            }
+
+        } while (!asleep);
+
+        if (asleep) {
+            assertTrue("Sleeping on an incorrect message", MESSAGE.equals(msg));
+        }
+
+        return true;
+    }
+    
+
+    private AsyncService getService(Executor ex) {
+        AsyncService service = new AsyncService();
+
+        if (ex!= null)
+            service.setExecutor(ex);
+        
+        if (service.getExecutor() == null)
+        {
+            System.out.println(myClassName+" : getService() : executor is null");
+        }
+        else
+        {
+            System.out.println(myClassName+" : getService() : executor is available ");
+        }
+
+        return service;
+    }
+
+
+    private AsyncPort getPort(AsyncService service) {
+
+        AsyncPort port = service.getAsyncPort();
+        assertNotNull("Port is null", port);
+
+        Map<String, Object> rc = ((BindingProvider) port).getRequestContext();
+        rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+                DOCLITWR_ASYNC_ENDPOINT);
+        
+        return port;
+
+    }
+
+    /**
+     * Auxiliary method used for obtaining a proxy pre-configured with a
+     * specific Executor
+     */
+    private AsyncPort getPort(Executor ex) {
+        AsyncService service = getService(ex);
+
+        AsyncPort port = service.getAsyncPort();
+        assertNotNull("Port is null", port);
+
+        Map<String, Object> rc = ((BindingProvider) port).getRequestContext();
+        rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+                DOCLITWR_ASYNC_ENDPOINT);
+        
+        return port;
+    }
+    
+    private void waitBlocking(Future<?> monitor){
+        while (!monitor.isDone()){
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+            }
+        }
+    }
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/parallelasync/server/AsyncPort.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/parallelasync/server/AsyncPort.java?view=diff&rev=507358&r1=507357&r2=507358
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/parallelasync/server/AsyncPort.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/parallelasync/server/AsyncPort.java Tue Feb 13 18:13:51 2007
@@ -1,298 +1,276 @@
-/*
- * 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.axis2.jaxws.sample.parallelasync.server;
-
-import java.util.concurrent.Future;
-
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
-import javax.jws.WebResult;
-import javax.jws.WebService;
-import javax.xml.ws.AsyncHandler;
-import javax.xml.ws.Holder;
-import javax.xml.ws.RequestWrapper;
-import javax.xml.ws.Response;
-import javax.xml.ws.ResponseWrapper;
-
-import org.test.parallelasync.AnotherResponse;
-import org.test.parallelasync.CustomAsyncResponse;
-import org.test.parallelasync.InvokeAsyncResponse;
-import org.test.parallelasync.PingResponse;
-import org.test.parallelasync.SleepResponse;
-
-/**
- * This class was generated by the JAXWS SI.
- * JAX-WS RI 2.0.1-jaxws-rearch-2005-nightly_2006-08-16_02-32-03-M1
- * Generated source version: 2.0
- * 
- */
-@WebService(name = "AsyncPort", targetNamespace = "http://org/test/parallelasync")
-public interface AsyncPort {
-
-
-    /**
-     * 
-     * @param message
-     * @return
-     *     returns javax.xml.ws.Response<org.test.parallelasync.PingResponse>
-     */
-    @WebMethod(operationName = "ping", action = "http://org/test/parallelasync/ping")
-    @RequestWrapper(localName = "ping", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Ping")
-    @ResponseWrapper(localName = "pingResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.PingResponse")
-    public Response<PingResponse> pingAsync(
-        @WebParam(name = "message", targetNamespace = "")
-        String message);
-
-    /**
-     * 
-     * @param message
-     * @param asyncHandler
-     * @return
-     *     returns java.util.concurrent.Future<? extends java.lang.Object>
-     */
-    @WebMethod(operationName = "ping", action = "http://org/test/parallelasync/ping")
-    @RequestWrapper(localName = "ping", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Ping")
-    @ResponseWrapper(localName = "pingResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.PingResponse")
-    public Future<?> pingAsync(
-        @WebParam(name = "message", targetNamespace = "")
-        String message,
-        @WebParam(name = "asyncHandler", targetNamespace = "")
-        AsyncHandler<PingResponse> asyncHandler);
-
-    /**
-     * 
-     * @param message
-     * @return
-     *     returns java.lang.String
-     */
-    @WebMethod(action = "http://org/test/parallelasync/ping")
-    @WebResult(name = "response", targetNamespace = "")
-    @RequestWrapper(localName = "ping", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Ping")
-    @ResponseWrapper(localName = "pingResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.PingResponse")
-    public String ping(
-        @WebParam(name = "message", targetNamespace = "")
-        String message);
-
-    /**
-     * 
-     * @param message
-     * @return
-     *     returns javax.xml.ws.Response<org.test.parallelasync.SleepResponse>
-     */
-    @WebMethod(operationName = "sleep", action = "http://org/test/parallelasync/sleep")
-    @RequestWrapper(localName = "sleep", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Sleep")
-    @ResponseWrapper(localName = "sleepResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.SleepResponse")
-    public Response<SleepResponse> sleepAsync(
-        @WebParam(name = "message", targetNamespace = "")
-        String message);
-
-    /**
-     * 
-     * @param message
-     * @param asyncHandler
-     * @return
-     *     returns java.util.concurrent.Future<? extends java.lang.Object>
-     */
-    @WebMethod(operationName = "sleep", action = "http://org/test/parallelasync/sleep")
-    @RequestWrapper(localName = "sleep", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Sleep")
-    @ResponseWrapper(localName = "sleepResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.SleepResponse")
-    public Future<?> sleepAsync(
-        @WebParam(name = "message", targetNamespace = "")
-        String message,
-        @WebParam(name = "asyncHandler", targetNamespace = "")
-        AsyncHandler<SleepResponse> asyncHandler);
-
-    /**
-     * 
-     * @param message
-     */
-    @WebMethod(action = "http://org/test/parallelasync/sleep")
-    @RequestWrapper(localName = "sleep", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Sleep")
-    @ResponseWrapper(localName = "sleepResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.SleepResponse")
-    public void sleep(
-        @WebParam(name = "message", targetNamespace = "", mode = WebParam.Mode.INOUT)
-        Holder<String> message);
-
-    /**
-     * 
-     * @return
-     *     returns java.lang.String
-     */
-    @WebMethod(action = "http://org/test/parallelasync/isAsleep")
-    @WebResult(name = "message", targetNamespace = "")
-    @RequestWrapper(localName = "isAsleep", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.IsAsleep")
-    @ResponseWrapper(localName = "isAsleepResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.IsAsleepResponse")
-    public String isAsleep();
-
-    /**
-     * 
-     * @return
-     *     returns java.lang.String
-     */
-    @WebMethod(action = "http://org/test/parallelasync/wakeUp")
-    @WebResult(name = "message", targetNamespace = "")
-    @RequestWrapper(localName = "wakeUp", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.WakeUp")
-    @ResponseWrapper(localName = "wakeUpResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.WakeUpResponse")
-    public String wakeUp();
-
-    /**
-     * 
-     * @param request
-     * @return
-     *     returns javax.xml.ws.Response<org.test.parallelasync.InvokeAsyncResponse>
-     */
-    @WebMethod(operationName = "invokeAsync", action = "http://org/test/parallelasync/invokeAsync")
-    @RequestWrapper(localName = "invokeAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.InvokeAsync")
-    @ResponseWrapper(localName = "invokeAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.InvokeAsyncResponse")
-    public Response<InvokeAsyncResponse> invokeAsyncAsync(
-        @WebParam(name = "request", targetNamespace = "")
-        String request);
-
-    /**
-     * 
-     * @param asyncHandler
-     * @param request
-     * @return
-     *     returns java.util.concurrent.Future<? extends java.lang.Object>
-     */
-    @WebMethod(operationName = "invokeAsync", action = "http://org/test/parallelasync/invokeAsync")
-    @RequestWrapper(localName = "invokeAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.InvokeAsync")
-    @ResponseWrapper(localName = "invokeAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.InvokeAsyncResponse")
-    public Future<?> invokeAsyncAsync(
-        @WebParam(name = "request", targetNamespace = "")
-        String request,
-        @WebParam(name = "asyncHandler", targetNamespace = "")
-        AsyncHandler<InvokeAsyncResponse> asyncHandler);
-
-    /**
-     * 
-     * @param request
-     * @return
-     *     returns java.lang.String
-     */
-    @WebMethod(action = "http://org/test/parallelasync/invokeAsync")
-    @WebResult(name = "response", targetNamespace = "")
-    @RequestWrapper(localName = "invokeAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.InvokeAsync")
-    @ResponseWrapper(localName = "invokeAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.InvokeAsyncResponse")
-    public String invokeAsync(
-        @WebParam(name = "request", targetNamespace = "")
-        String request);
-
-    /**
-     * 
-     * @param request
-     * @return
-     *     returns javax.xml.ws.Response<org.test.parallelasync.CustomAsyncResponse>
-     */
-    @WebMethod(operationName = "customAsync", action = "http://org/test/parallelasync/customAsync")
-    @RequestWrapper(localName = "customAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsync")
-    @ResponseWrapper(localName = "customAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsyncResponse")
-    public Response<CustomAsyncResponse> remappedAsync(
-        @WebParam(name = "request", targetNamespace = "")
-        String request);
-
-    /**
-     * 
-     * @param asyncHandler
-     * @param request
-     * @return
-     *     returns java.util.concurrent.Future<? extends java.lang.Object>
-     */
-    @WebMethod(operationName = "customAsync", action = "http://org/test/parallelasync/customAsync")
-    @RequestWrapper(localName = "customAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsync")
-    @ResponseWrapper(localName = "customAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsyncResponse")
-    public Future<?> remappedAsync(
-        @WebParam(name = "request", targetNamespace = "")
-        String request,
-        @WebParam(name = "asyncHandler", targetNamespace = "")
-        AsyncHandler<CustomAsyncResponse> asyncHandler);
-
-    /**
-     * 
-     * @param request
-     * @return
-     *     returns java.lang.String
-     */
-    @WebMethod(operationName = "customAsync", action = "http://org/test/parallelasync/customAsync")
-    @WebResult(name = "response", targetNamespace = "")
-    @RequestWrapper(localName = "customAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsync")
-    @ResponseWrapper(localName = "customAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsyncResponse")
-    public String remapped(
-        @WebParam(name = "request", targetNamespace = "")
-        String request);
-
-    /**
-     * 
-     * @param request
-     * @return
-     *     returns javax.xml.ws.Response<org.test.parallelasync.AnotherResponse>
-     */
-    @WebMethod(operationName = "another", action = "http://org/test/parallelasync/another")
-    @RequestWrapper(localName = "another", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Another")
-    @ResponseWrapper(localName = "anotherResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.AnotherResponse")
-    public Response<AnotherResponse> anotherAsyncAsync(
-        @WebParam(name = "request", targetNamespace = "")
-        String request);
-
-    /**
-     * 
-     * @param asyncHandler
-     * @param request
-     * @return
-     *     returns java.util.concurrent.Future<? extends java.lang.Object>
-     */
-    @WebMethod(operationName = "another", action = "http://org/test/parallelasync/another")
-    @RequestWrapper(localName = "another", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Another")
-    @ResponseWrapper(localName = "anotherResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.AnotherResponse")
-    public Future<?> anotherAsyncAsync(
-        @WebParam(name = "request", targetNamespace = "")
-        String request,
-        @WebParam(name = "asyncHandler", targetNamespace = "")
-        AsyncHandler<AnotherResponse> asyncHandler);
-
-    /**
-     * 
-     * @param request
-     * @return
-     *     returns java.lang.String
-     */
-    @WebMethod(operationName = "another", action = "http://org/test/parallelasync/another")
-    @WebResult(name = "response", targetNamespace = "")
-    @RequestWrapper(localName = "another", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Another")
-    @ResponseWrapper(localName = "anotherResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.AnotherResponse")
-    public String anotherAsync(
-        @WebParam(name = "request", targetNamespace = "")
-        String request);
-    
-    /**
-     * 
-     * @param request
-     * @return
-     *     returns java.lang.String
-     */
-    @WebMethod(operationName = "realCustomAsync", action = "http://org/test/parallelasync/customAsync")
-    @WebResult(name = "response", targetNamespace = "")
-    @RequestWrapper(localName = "customAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsync")
-    @ResponseWrapper(localName = "customAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsyncResponse")
-    public String customAsync(
-        @WebParam(name = "request", targetNamespace = "")
-        String request);
-
-}
+/*
+ * 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.axis2.jaxws.sample.parallelasync.server;
+
+import java.util.concurrent.Future;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Holder;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.Response;
+import javax.xml.ws.ResponseWrapper;
+
+import org.test.parallelasync.AnotherResponse;
+import org.test.parallelasync.CustomAsyncResponse;
+import org.test.parallelasync.InvokeAsyncResponse;
+import org.test.parallelasync.IsAsleepResponse;
+import org.test.parallelasync.PingResponse;
+import org.test.parallelasync.SleepResponse;
+import org.test.parallelasync.WakeUpResponse;
+
+/**
+ * This class was generated by the JAXWS SI.
+ * JAX-WS RI 2.0.1-jaxws-rearch-2005-nightly_2006-08-16_02-32-03-M1
+ * Generated source version: 2.0
+ * 
+ */
+@WebService(name = "AsyncPort", targetNamespace = "http://org/test/parallelasync")
+public interface AsyncPort {
+
+
+    /**
+     * 
+     * @param request
+     * @return
+     *     returns java.lang.String
+     */
+    @WebMethod(action = "http://org/test/parallelasync/ping")
+    @WebResult(name = "response", targetNamespace = "")
+    @RequestWrapper(localName = "ping", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Ping")
+    @ResponseWrapper(localName = "pingResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.PingResponse")
+    public String ping(
+        @WebParam(name = "request", targetNamespace = "")
+        String request);
+
+    /**
+     * 
+     * @param message
+     * @return
+     *     returns javax.xml.ws.Response<org.test.parallelasync.SleepResponse>
+     */
+    @WebMethod(operationName = "sleep", action = "http://org/test/parallelasync/sleep")
+    @RequestWrapper(localName = "sleep", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Sleep")
+    @ResponseWrapper(localName = "sleepResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.SleepResponse")
+    public Response<SleepResponse> sleepAsync(
+        @WebParam(name = "message", targetNamespace = "")
+        String message);
+
+    /**
+     * 
+     * @param message
+     * @param asyncHandler
+     * @return
+     *     returns java.util.concurrent.Future<? extends java.lang.Object>
+     */
+    @WebMethod(operationName = "sleep", action = "http://org/test/parallelasync/sleep")
+    @RequestWrapper(localName = "sleep", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Sleep")
+    @ResponseWrapper(localName = "sleepResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.SleepResponse")
+    public Future<?> sleepAsync(
+        @WebParam(name = "message", targetNamespace = "")
+        String message,
+        @WebParam(name = "asyncHandler", targetNamespace = "")
+        AsyncHandler<SleepResponse> asyncHandler);
+
+    /**
+     * 
+     * @param message
+     */
+    @WebMethod(action = "http://org/test/parallelasync/sleep")
+    @RequestWrapper(localName = "sleep", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Sleep")
+    @ResponseWrapper(localName = "sleepResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.SleepResponse")
+    public void sleep(
+        @WebParam(name = "message", targetNamespace = "", mode = WebParam.Mode.INOUT)
+        Holder<String> message);
+
+
+    /**
+     * 
+     * @return
+     *     returns java.lang.String
+     */
+    @WebMethod(action = "http://org/test/parallelasync/isAsleep")
+    @WebResult(name = "response", targetNamespace = "")
+    @RequestWrapper(localName = "isAsleep", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.IsAsleep")
+    @ResponseWrapper(localName = "isAsleepResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.IsAsleepResponse")
+    public String isAsleep(
+        @WebParam(name = "request", targetNamespace = "")
+        String request);
+
+    /**
+     * 
+     * @return
+     *     returns java.lang.String
+     */
+    @WebMethod(action = "http://org/test/parallelasync/wakeUp")
+    @WebResult(name = "response", targetNamespace = "")
+    @RequestWrapper(localName = "wakeUp", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.WakeUp")
+    @ResponseWrapper(localName = "wakeUpResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.WakeUpResponse")
+    public String wakeUp(
+        @WebParam(name = "request", targetNamespace = "")
+        String request);
+
+    /**
+     * 
+     * @param request
+     * @return
+     *     returns javax.xml.ws.Response<org.test.parallelasync.InvokeAsyncResponse>
+     */
+    @WebMethod(operationName = "invokeAsync", action = "http://org/test/parallelasync/invokeAsync")
+    @RequestWrapper(localName = "invokeAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.InvokeAsync")
+    @ResponseWrapper(localName = "invokeAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.InvokeAsyncResponse")
+    public Response<InvokeAsyncResponse> invokeAsyncAsync(
+        @WebParam(name = "request", targetNamespace = "")
+        String request);
+
+    /**
+     * 
+     * @param asyncHandler
+     * @param request
+     * @return
+     *     returns java.util.concurrent.Future<? extends java.lang.Object>
+     */
+    @WebMethod(operationName = "invokeAsync", action = "http://org/test/parallelasync/invokeAsync")
+    @RequestWrapper(localName = "invokeAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.InvokeAsync")
+    @ResponseWrapper(localName = "invokeAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.InvokeAsyncResponse")
+    public Future<?> invokeAsyncAsync(
+        @WebParam(name = "request", targetNamespace = "")
+        String request,
+        @WebParam(name = "asyncHandler", targetNamespace = "")
+        AsyncHandler<InvokeAsyncResponse> asyncHandler);
+
+    /**
+     * 
+     * @param request
+     * @return
+     *     returns java.lang.String
+     */
+    @WebMethod(action = "http://org/test/parallelasync/invokeAsync")
+    @WebResult(name = "response", targetNamespace = "")
+    @RequestWrapper(localName = "invokeAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.InvokeAsync")
+    @ResponseWrapper(localName = "invokeAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.InvokeAsyncResponse")
+    public String invokeAsync(
+        @WebParam(name = "request", targetNamespace = "")
+        String request);
+
+    /**
+     * 
+     * @param request
+     * @return
+     *     returns javax.xml.ws.Response<org.test.parallelasync.CustomAsyncResponse>
+     */
+    @WebMethod(operationName = "customAsync", action = "http://org/test/parallelasync/customAsync")
+    @RequestWrapper(localName = "customAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsync")
+    @ResponseWrapper(localName = "customAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsyncResponse")
+    public Response<CustomAsyncResponse> remappedAsync(
+        @WebParam(name = "request", targetNamespace = "")
+        String request);
+
+    /**
+     * 
+     * @param asyncHandler
+     * @param request
+     * @return
+     *     returns java.util.concurrent.Future<? extends java.lang.Object>
+     */
+    @WebMethod(operationName = "customAsync", action = "http://org/test/parallelasync/customAsync")
+    @RequestWrapper(localName = "customAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsync")
+    @ResponseWrapper(localName = "customAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsyncResponse")
+    public Future<?> remappedAsync(
+        @WebParam(name = "request", targetNamespace = "")
+        String request,
+        @WebParam(name = "asyncHandler", targetNamespace = "")
+        AsyncHandler<CustomAsyncResponse> asyncHandler);
+
+    /**
+     * 
+     * @param request
+     * @return
+     *     returns java.lang.String
+     */
+    @WebMethod(operationName = "customAsync", action = "http://org/test/parallelasync/customAsync")
+    @WebResult(name = "response", targetNamespace = "")
+    @RequestWrapper(localName = "customAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsync")
+    @ResponseWrapper(localName = "customAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsyncResponse")
+    public String remapped(
+        @WebParam(name = "request", targetNamespace = "")
+        String request);
+
+    /**
+     * 
+     * @param request
+     * @return
+     *     returns javax.xml.ws.Response<org.test.parallelasync.AnotherResponse>
+     */
+    @WebMethod(operationName = "another", action = "http://org/test/parallelasync/another")
+    @RequestWrapper(localName = "another", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Another")
+    @ResponseWrapper(localName = "anotherResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.AnotherResponse")
+    public Response<AnotherResponse> anotherAsyncAsync(
+        @WebParam(name = "request", targetNamespace = "")
+        String request);
+
+    /**
+     * 
+     * @param asyncHandler
+     * @param request
+     * @return
+     *     returns java.util.concurrent.Future<? extends java.lang.Object>
+     */
+    @WebMethod(operationName = "another", action = "http://org/test/parallelasync/another")
+    @RequestWrapper(localName = "another", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Another")
+    @ResponseWrapper(localName = "anotherResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.AnotherResponse")
+    public Future<?> anotherAsyncAsync(
+        @WebParam(name = "request", targetNamespace = "")
+        String request,
+        @WebParam(name = "asyncHandler", targetNamespace = "")
+        AsyncHandler<AnotherResponse> asyncHandler);
+
+    /**
+     * 
+     * @param request
+     * @return
+     *     returns java.lang.String
+     */
+    @WebMethod(operationName = "another", action = "http://org/test/parallelasync/another")
+    @WebResult(name = "response", targetNamespace = "")
+    @RequestWrapper(localName = "another", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.Another")
+    @ResponseWrapper(localName = "anotherResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.AnotherResponse")
+    public String anotherAsync(
+        @WebParam(name = "request", targetNamespace = "")
+        String request);
+    
+    /**
+     * 
+     * @param request
+     * @return
+     *     returns java.lang.String
+     */
+    @WebMethod(operationName = "realCustomAsync", action = "http://org/test/parallelasync/customAsync")
+    @WebResult(name = "response", targetNamespace = "")
+    @RequestWrapper(localName = "customAsync", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsync")
+    @ResponseWrapper(localName = "customAsyncResponse", targetNamespace = "http://org/test/parallelasync", className = "org.test.parallelasync.CustomAsyncResponse")
+    public String customAsync(
+        @WebParam(name = "request", targetNamespace = "")
+        String request);
+
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/parallelasync/server/DocLitWrappedPortImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/parallelasync/server/DocLitWrappedPortImpl.java?view=diff&rev=507358&r1=507357&r2=507358
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/parallelasync/server/DocLitWrappedPortImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/parallelasync/server/DocLitWrappedPortImpl.java Tue Feb 13 18:13:51 2007
@@ -1,239 +1,410 @@
-/*
- * 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.axis2.jaxws.sample.parallelasync.server;
-
-import java.util.concurrent.Future;
-
-import javax.jws.WebService;
-import javax.xml.ws.AsyncHandler;
-import javax.xml.ws.Holder;
-import javax.xml.ws.Response;
-
-import org.apache.axis2.jaxws.sample.parallelasync.common.Constants;
-import org.test.parallelasync.AnotherResponse;
-import org.test.parallelasync.CustomAsyncResponse;
-import org.test.parallelasync.InvokeAsyncResponse;
-import org.test.parallelasync.PingResponse;
-import org.test.parallelasync.SleepResponse;
-
-/**
- * Async endpoint used for Async client side tests. Clients will invokeAsync
- * sleep method to force the server to block until wakeUp is called. The client
- * can call isAsleep to verify that sleep has been called by the async thread.
- */
-/*
-@WebService(
-        serviceName="AsyncService",
-        portName="AsyncPort",
-        targetNamespace = "http://org/test/parallelasync",
-        endpointInterface = "org.test.parallelasync.AsyncPort",
-        wsdlLocation="WEB-INF/wsdl/async_doclitwr.wsdl")
-        */
-@WebService(endpointInterface="org.apache.axis2.jaxws.sample.parallelasync.server.AsyncPort")
-public class DocLitWrappedPortImpl implements AsyncPort {
-
-    private static final boolean DEBUG = true;
-
-    private static String msg = "";
-
-    private static Thread sleeper = null;
-
-    private static boolean doCancell = false;
-
-    public void sleep(Holder<String> message) {
-
-        boolean cancelRequested = false;
-
-        msg = message.value;
-
-        synchronized (msg) {
-
-            Thread myThread = Thread.currentThread();
-            sleeper = myThread;
-
-            try {
-
-                doCancell = false;
-
-                if (DEBUG)
-                    System.out.println("Starting to sleep on "
-                            + myThread.getId() + " " + msg);
-
-                // wait until either a timeout or client releases us
-                // or if another request begins (lockId changes)
-                long sec = Constants.SERVER_SLEEP_SEC;
-
-                while (sec > 0 && !doCancell && sleeper == myThread) {
-                    if (DEBUG)
-                        System.out.println("Sleeping on " + myThread.getId()
-                                + " timeLeft=" + sec);
-                    sec--;
-
-                    msg.wait(500);
-                }
-            } catch (InterruptedException e) {
-                System.out.println("Sleep interrupted on " + myThread.getId());
-            } finally {
-
-                if (DEBUG)
-                    System.out.println("Woke up " + myThread.getId());
-
-                // if we timed out while waiting then
-                // release the wait
-                if (sleeper == myThread) {
-                    cancelRequested = doCancell;
-                    doCancell = false;
-                    sleeper = null;
-                }
-
-                // only notify if cancel was requested
-                if (cancelRequested) {
-                    if (DEBUG)
-                        System.out.println("Notify " + myThread.getId()
-                                + " isDone");
-
-                    // wake up the release thread
-                    msg.notify();
-                }
-            }
-        }// synch
-    }
-
-    public String isAsleep() {
-
-        // return the message we're sleeping on or if we aren't return a null
-        return (sleeper != null) ? msg : null;
-    }
-
-    public String wakeUp() {
-
-        String wakeUp = null;
-
-        if (sleeper == null) {
-            if (DEBUG)
-                System.out.println("No one to wake up");
-        } else {
-            if (DEBUG)
-                System.out.println("Interrupting " + sleeper.getId());
-
-            // interrupt the sleeper
-            sleeper.interrupt();
-
-            if (DEBUG)
-                System.out.println("release before synched");
-
-            // block until sleep completes
-            synchronized (msg) {
-
-                if (DEBUG)
-                    System.out.println("release enter synched");
-
-                wakeUp = msg;
-                msg = null;
-            }
-        }
-
-        return wakeUp;
-    }
-
-    /**
-     * client side tests for remapping operation names, on the server side all
-     * we need to do is roundtrip the message
-     */
-
-    public String invokeAsync(String request) {
-        return request;
-    }
-
-    public String customAsync(String request) {
-        return request + "from customAsync method";
-    }
-
-    public String another(String request) {
-        return request;
-    }
-
-    public String ping(String message) {
-        return message;
-    }
-
-    // NOT USED:
-    
-    public String anotherAsync(String request) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Future<?> anotherAsyncAsync(String request, AsyncHandler<AnotherResponse> asyncHandler) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Response<AnotherResponse> anotherAsyncAsync(String request) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Future<?> invokeAsyncAsync(String request, AsyncHandler<InvokeAsyncResponse> asyncHandler) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Response<InvokeAsyncResponse> invokeAsyncAsync(String request) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Future<?> pingAsync(String message, AsyncHandler<PingResponse> asyncHandler) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Response<PingResponse> pingAsync(String message) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public String remapped(String request) {
-        // TODO Auto-generated method stub
-        return request;
-    }
-
-    public Future<?> remappedAsync(String request, AsyncHandler<CustomAsyncResponse> asyncHandler) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Response<CustomAsyncResponse> remappedAsync(String request) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Future<?> sleepAsync(String message, AsyncHandler<SleepResponse> asyncHandler) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Response<SleepResponse> sleepAsync(String message) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-    
-}
+/*
+ * 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.axis2.jaxws.sample.parallelasync.server;
+
+import java.util.concurrent.Future;      
+import java.util.Hashtable;
+
+import javax.jws.WebService;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Holder;
+import javax.xml.ws.Response;
+
+import org.apache.axis2.jaxws.sample.parallelasync.common.Constants;
+import org.test.parallelasync.AnotherResponse;
+import org.test.parallelasync.CustomAsyncResponse;
+import org.test.parallelasync.InvokeAsyncResponse;
+import org.test.parallelasync.PingResponse;
+import org.test.parallelasync.SleepResponse;
+
+/**
+ * Async endpoint used for Async client side tests. Clients will invokeAsync
+ * sleep method to force the server to block until wakeUp is called. The client
+ * can call isAsleep to verify that sleep has been called by the async thread.
+ */
+/*
+@WebService(
+        serviceName="AsyncService",
+        portName="AsyncPort",
+        targetNamespace = "http://org/test/parallelasync",
+        endpointInterface = "org.test.parallelasync.AsyncPort",
+        wsdlLocation="WEB-INF/wsdl/async_doclitwr.wsdl")
+        */
+@WebService(endpointInterface="org.apache.axis2.jaxws.sample.parallelasync.server.AsyncPort")
+public class DocLitWrappedPortImpl implements AsyncPort {
+
+    private static final boolean DEBUG = false;
+
+    // in order to allow multiple sleeping requests to be held at the same time
+    // use a table where 
+    //       the key is the request string
+    //       the value is the object used to block on
+    //
+    private static Hashtable sleepers = new Hashtable();
+
+    // intended to flag the need to cancel current requests being held (ie, sleeping)
+    // does not stop new requests
+    // not settable yet
+    // need to determine when to reset it when dealing with multiple operations
+    // currently reset when the sleepers table doesn't have any more requests
+    private static boolean doCancell = false;
+
+    // strings used for logging
+    private String myClassName = "DocLitWrappedPortImpl.";
+
+
+
+    /**
+     * This operation takes the request and holds it in the web service until
+     * <UL>
+     * <LI>the client asks for it via wakeUp()
+     * <LI>the operation times out
+     * <LI>the operation is interrupted
+     * </UL>
+     * 
+     * @param request The request identifier
+     */
+    public void sleep(Holder<String> request) {
+
+        boolean cancelRequested = false;
+
+        String key = new String(request.value);
+        String msg = request.value;
+
+        String title = myClassName+"sleep("+msg+"): ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "] ";
+        //if (DEBUG)
+        //{
+        //    System.out.println(title + tid + "Enter");
+        //}
+
+        if (sleepers.get(key) != null)
+        {
+            // already holding this request id
+            return;
+        }
+
+        Thread myThread = Thread.currentThread();
+        long threadID = myThread.getId();
+
+        // add this request to our list
+        sleepers.put(key,myThread);
+
+        // set the timeout value
+        long sec = Constants.SERVER_SLEEP_SEC;
+
+        try {
+
+            //if (DEBUG)
+            //    System.out.println(title + "Starting to sleep on "
+            //            + " threadID ["+ threadID + "]" );
+
+            // hold this request until
+            //  - the wait time expires
+            //  - the client explicits asks for this request via wakeUp()
+            //  - the wait is interrupted
+            //  - a cancel occurs
+
+            while (sec > 0 && !doCancell) {
+                if (DEBUG)
+                    System.out.println(title + "Sleeping on " 
+                            + " threadID ["+ threadID + "]" 
+                            + " timeLeft=" + sec);
+                sec--;
+
+                //msg.wait(500);
+                myThread.sleep(500);
+            }
+
+        } 
+        catch (InterruptedException e) {
+
+            System.out.println(title + "Sleep interrupted on " 
+                                     + " threadID ["+ threadID + "]"
+                                     + " timeLeft=["+sec+"]");  
+
+        } 
+        finally {
+
+            if (DEBUG)
+                System.out.println(title + "final processing for " 
+                                         + " threadID ["+ threadID + "]"); 
+
+            // remove this request from the list
+            sleepers.remove(key);
+
+            // for now, reset the cancellation flag when the list of 
+            // waiting requests go to zero
+            if (sleepers.isEmpty())
+            {
+                doCancell = false;
+            }
+        }
+
+    }
+
+    /**
+     * Checks the specified request to determine whether
+     * it is still being held by the web service.
+     * 
+     * @param request The request identifier to check
+     * @return The String being used as a wait object if the
+     *         request is still being held by the server
+     *         or NULL if the request is not held by the server
+     */
+    public String isAsleep(String request) {
+
+        String title = myClassName+"isAsleep("+request+"): ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "] ";
+
+        if (sleepers.isEmpty())
+        {
+            if (DEBUG)
+                System.out.println(title + tid + " Not sleeping");
+            return null;
+        }
+
+        Thread value = (Thread) sleepers.get(request);
+
+        if (value == null)
+        {
+            if (DEBUG)
+                System.out.println(title + tid + " Not sleeping");
+
+            return null;
+        }
+
+        if (DEBUG)
+            System.out.println(title + tid + " sleeping on ["+request+"]");
+
+        return request;
+    }
+
+
+
+    public String wakeUp(String request) {
+
+        String title = myClassName+"wakeUp(): ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+
+        if (sleepers.isEmpty())
+        {
+            if (DEBUG)
+                System.out.println(title + tid + " No one to wake up");
+
+            return null;
+        }
+
+        Thread value = (Thread) sleepers.get(request);
+
+        if (value == null)
+        {
+            if (DEBUG)
+                System.out.println(title + tid + " Thread not available. No one to wake up.");
+
+            return null;
+        }
+
+        if (DEBUG)
+            System.out.println(title + tid + " Interrupting " 
+                                     + " threadID ["+ value.getId() + "]"); 
+
+        // interrupt the sleeper
+        try
+        {
+            value.interrupt();
+        }
+        catch (Exception e)
+        {
+            if (DEBUG)
+                System.out.println(title + tid + " Interrupting " 
+                                         + " threadID ["+ value.getId() + "]  got Exception ["+e.getClass().getName()+"]   ["+e.getMessage()+"]"); 
+        }
+
+        return request;
+    }
+
+
+    /**
+     * client side tests for remapping operation names, on the server side all
+     * we need to do is roundtrip the message
+     */
+
+    public String invokeAsync(String request) {
+        String title = myClassName+"invokeAsync("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return request;
+    }
+
+    public String customAsync(String request) {
+        String title = myClassName+"customeAsync("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return request + "from customAsync method";
+    }
+
+    public String another(String request) {
+        String title = myClassName+"another("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return request;
+    }
+
+    public String ping(String request) {
+        String title = myClassName+"ping("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return request;
+    }
+
+
+    public String remapped(String request) {
+        // TODO Auto-generated method stub
+        String title = myClassName+"remapped("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return request;
+    }
+
+
+    // NOT USED:
+    
+    public String anotherAsync(String request) {
+        // TODO Auto-generated method stub
+        String title = myClassName+"anotherAsync("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return null;
+    }
+
+    public Future<?> anotherAsyncAsync(String request, AsyncHandler<AnotherResponse> asyncHandler) {
+        // TODO Auto-generated method stub
+        String title = myClassName+" Future<?> anotherAsyncAsync("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return null;
+    }
+
+    public Response<AnotherResponse> anotherAsyncAsync(String request) {
+        // TODO Auto-generated method stub
+        String title = myClassName+" Response<AnotherResponse> anotherAsyncAsync("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return null;
+    }
+
+    public Future<?> invokeAsyncAsync(String request, AsyncHandler<InvokeAsyncResponse> asyncHandler) {
+        // TODO Auto-generated method stub
+        String title = myClassName+" Future<?> invokeAsyncAsync("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return null;
+    }
+
+    public Response<InvokeAsyncResponse> invokeAsyncAsync(String request) {
+        // TODO Auto-generated method stub
+        String title = myClassName+" Response<InvokeAsyncResponse> invokeAsyncAsync("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return null;
+    }
+
+    public Future<?> pingAsync(String request, AsyncHandler<PingResponse> asyncHandler) {
+        // TODO Auto-generated method stub
+        String title = myClassName+" Future<?> pingAsync("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return null;
+    }
+
+    public Response<PingResponse> pingAsync(String request) {
+        // TODO Auto-generated method stub
+        String title = myClassName+" Response<PingResponse> pingAsync("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return null;
+    }
+
+    public Future<?> remappedAsync(String request, AsyncHandler<CustomAsyncResponse> asyncHandler) {
+        // TODO Auto-generated method stub
+        String title = myClassName+" Future<?> remappedAsync("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return null;
+    }
+
+    public Response<CustomAsyncResponse> remappedAsync(String request) {
+        // TODO Auto-generated method stub
+        String title = myClassName+" Response<CustomAsyncResponse> remappedAsync("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return null;
+    }
+
+    public Future<?> sleepAsync(String request, AsyncHandler<SleepResponse> asyncHandler) {
+        // TODO Auto-generated method stub
+        String title = myClassName+" Future<?> sleepAsync("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return null;
+    }
+
+    public Response<SleepResponse> sleepAsync(String request) {
+        // TODO Auto-generated method stub
+        String title = myClassName+" Response<SleepResponse> sleepAsync("+request+") : ";
+        String tid = " threadID ["+ Thread.currentThread().getId() + "]";
+        if (DEBUG)
+            System.out.println(title + "Enter" + tid);
+
+        return null;
+    }
+    
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org