axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: ws-axis/java/test/client TestAsyncCall.java PackageTests.java
Date Sun, 22 Feb 2004 20:23:55 GMT
dims        2004/02/22 12:23:55

  Modified:    java/src/org/apache/axis/enum Enum.java
               java/test/client PackageTests.java
  Added:       java/src/org/apache/axis/client/async AsyncCall.java
                        AsyncResult.java IAsyncCallback.java
                        IAsyncResult.java Status.java
               java/test/client TestAsyncCall.java
  Log:
  Async support for Axis. See test/client/TestAsyncCall.java for current usage. Since James's
IME code has stalled (See http://marc.theaimsgroup.com/?l=axis-dev&m=105233711525903&w=2)
there has been zero activity in this area. Hopefully the Sonic folks (prev email about sync
was http://marc.theaimsgroup.com/?l=axis-dev&m=103903901501446&w=2) will help refine
the code and hook it upto James' IME when they get a chance.
  
  Revision  Changes    Path
  1.1                  ws-axis/java/src/org/apache/axis/client/async/AsyncCall.java
  
  Index: AsyncCall.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.client.async;
  
  import org.apache.axis.client.Call;
  
  import javax.xml.namespace.QName;
  
  /**
   * Support for Asynchronous call
   * 
   * @author Davanum Srinivas (dims@yahoo.com)
   */
  public class AsyncCall {
  
      /**
       * Field call
       */
      private Call call = null;
  
      /**
       * Field callback
       */
      private IAsyncCallback callback = null;
  
      /**
       * Constructor AsyncCall
       * 
       * @param call 
       */
      public AsyncCall(Call call) {
          this(call, null);
      }
  
      /**
       * Constructor AsyncCall
       * 
       * @param call     
       * @param callback 
       */
      public AsyncCall(Call call, IAsyncCallback callback) {
          this.call = call;
          this.callback = callback;
      }
  
      /**
       * Method getCallback
       * 
       * @return 
       */
      public IAsyncCallback getCallback() {
          return callback;
      }
  
      /**
       * Method setCallback
       * 
       * @param callback 
       */
      public void setCallback(IAsyncCallback callback) {
          this.callback = callback;
      }
  
      /**
       * Method invoke
       * 
       * @param inputParams 
       * @return 
       */
      public IAsyncResult invoke(Object[] inputParams) {
          return new AsyncResult(this, null, inputParams);
      }
  
      /**
       * Method invoke
       * 
       * @param qName       
       * @param inputParams 
       * @return 
       */
      public IAsyncResult invoke(QName qName, Object[] inputParams) {
          return new AsyncResult(this, qName, inputParams);
      }
  
      /**
       * Method getCall
       * 
       * @return 
       */
      public Call getCall() {
          return call;
      }
  }
  
  
  
  1.1                  ws-axis/java/src/org/apache/axis/client/async/AsyncResult.java
  
  Index: AsyncResult.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.client.async;
  
  import javax.xml.namespace.QName;
  
  /**
   * Access the results of the Async call
   * 
   * @author Davanum Srinivas (dims@yahoo.com)
   */
  public class AsyncResult implements IAsyncResult, Runnable {
  
      /**
       * Field thread
       */
      private Thread thread = null;
  
      /**
       * Field response
       */
      private Object response = null;
  
      /**
       * Field exception
       */
      private Throwable exception = null;
  
      /**
       * Field ac
       */
      private AsyncCall ac = null;
  
      /**
       * Field opName
       */
      private QName opName = null;
  
      /**
       * Field params
       */
      private Object[] params = null;
  
      /**
       * Field status
       */
      private Status status = Status.NONE;
  
      /**
       * Constructor AsyncResult
       * 
       * @param ac     
       * @param opName 
       * @param params 
       */
      public AsyncResult(AsyncCall ac, QName opName, Object[] params) {
          this.ac = ac;
          this.opName = opName;
          this.params = params;
  
          if (opName == null) {
              this.opName = ac.getCall().getOperationName();
          }
  
          thread = new Thread(this);
          thread.setDaemon(true);
          thread.start();
      }
  
      /**
       * Method abort
       */
      public void abort() {
          thread.interrupt();
          status = Status.INTERRUPTED;
      }
  
      /**
       * Method getStatus
       * 
       * @return 
       */
      public Status getStatus() {
          return status;
      }
  
      /**
       * Method waitFor
       * 
       * @param timeout 
       * @throws InterruptedException 
       */
      public void waitFor(long timeout) throws InterruptedException {
          thread.wait(timeout);
      }
  
      /**
       * Method getResponse
       * 
       * @return 
       */
      public Object getResponse() {
          return response;
      }
  
      /**
       * Method getException
       * 
       * @return 
       */
      public Throwable getException() {
          return exception;
      }
  
      /**
       * Method run
       */
      public void run() {
          try {
              response = ac.getCall().invoke(opName, params);
              status = Status.COMPLETED;
          } catch (Throwable e) {
              exception = e;
              status = Status.EXCEPTION;
          } finally {
              IAsyncCallback callback = ac.getCallback();
              if (callback != null) {
                  callback.onCompletion(this);
              }
          }
      }
  }
  
  
  
  1.1                  ws-axis/java/src/org/apache/axis/client/async/IAsyncCallback.java
  
  Index: IAsyncCallback.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.client.async;
  
  /**
   * Callback for Async notification
   * 
   * @author Davanum Srinivas (dims@yahoo.com)
   */
  public interface IAsyncCallback {
  
      /**
       * Method onCompletion
       * 
       * @param event 
       */
      public void onCompletion(IAsyncResult event);
  }
  
  
  
  1.1                  ws-axis/java/src/org/apache/axis/client/async/IAsyncResult.java
  
  Index: IAsyncResult.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.client.async;
  
  /**
   * Access the results of the Async call
   * 
   * @author Davanum Srinivas (dims@yahoo.com)
   */
  public interface IAsyncResult {
  
      /**
       * Method abort
       */
      public void abort();
  
      /**
       * Method getStatus
       * 
       * @return 
       */
      public Status getStatus();
  
      /**
       * Method waitFor
       * 
       * @param timeout 
       * @throws InterruptedException 
       */
      public void waitFor(long timeout) throws InterruptedException;
  
      /**
       * Method getResponse
       * 
       * @return 
       */
      public Object getResponse();
  
      /**
       * Method getException
       * 
       * @return 
       */
      public Throwable getException();
  }
  
  
  
  1.1                  ws-axis/java/src/org/apache/axis/client/async/Status.java
  
  Index: Status.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.client.async;
  
  import org.apache.axis.enum.Enum;
  
  /**
   * Status of the async request
   * 
   * @author Davanum Srinivas (dims@yahoo.com)
   */
  public class Status extends Enum {
  
      /**
       * Field type
       */
      private static final Type type = new Type();
  
      /**
       * Field NONE_STR
       */
      public static final String NONE_STR = "none";
  
      /**
       * Field INTERRUPTED_STR
       */
      public static final String INTERRUPTED_STR = "interrupted";
  
      /**
       * Field COMPLETED_STR
       */
      public static final String COMPLETED_STR = "completed";
  
      /**
       * Field EXCEPTION_STR
       */
      public static final String EXCEPTION_STR = "exception";
  
      /**
       * Field NONE
       */
      public static final Status NONE = type.getStatus(NONE_STR);
  
      /**
       * Field INTERRUPTED
       */
      public static final Status INTERRUPTED = type.getStatus(INTERRUPTED_STR);
  
      /**
       * Field COMPLETED
       */
      public static final Status COMPLETED = type.getStatus(COMPLETED_STR);
  
      /**
       * Field EXCEPTION
       */
      public static final Status EXCEPTION = type.getStatus(EXCEPTION_STR);
  
      /**
       * Field DEFAULT
       */
      public static final Status DEFAULT = NONE;
  
      static {
          type.setDefault(DEFAULT);
      }
  
      /**
       * Method getDefault
       * 
       * @return 
       */
      public static Status getDefault() {
          return (Status) type.getDefault();
      }
  
      /**
       * Method getStatus
       * 
       * @param style 
       * @return 
       */
      public static final Status getStatus(int style) {
          return type.getStatus(style);
      }
  
      /**
       * Method getStatus
       * 
       * @param style 
       * @return 
       */
      public static final Status getStatus(String style) {
          return type.getStatus(style);
      }
  
      /**
       * Method getStatus
       * 
       * @param style    
       * @param dephault 
       * @return 
       */
      public static final Status getStatus(String style, Status dephault) {
          return type.getStatus(style, dephault);
      }
  
      /**
       * Method isValid
       * 
       * @param style 
       * @return 
       */
      public static final boolean isValid(String style) {
          return type.isValid(style);
      }
  
      /**
       * Method size
       * 
       * @return 
       */
      public static final int size() {
          return type.size();
      }
  
      /**
       * Method getUses
       * 
       * @return 
       */
      public static final String[] getUses() {
          return type.getEnumNames();
      }
  
      /**
       * Class Type
       * 
       * @author 
       * @version %I%, %G%
       */
      public static class Type extends Enum.Type {
  
          /**
           * Constructor Type
           */
          private Type() {
  
              super("status", new Enum[]{new Status(0, NONE_STR),
                                         new Status(1, INTERRUPTED_STR),
                                         new Status(2, COMPLETED_STR),
                                         new Status(3, EXCEPTION_STR), });
          }
  
          /**
           * Method getStatus
           * 
           * @param status 
           * @return 
           */
          public final Status getStatus(int status) {
              return (Status) this.getEnum(status);
          }
  
          /**
           * Method getStatus
           * 
           * @param status 
           * @return 
           */
          public final Status getStatus(String status) {
              return (Status) this.getEnum(status);
          }
  
          /**
           * Method getStatus
           * 
           * @param status   
           * @param dephault 
           * @return 
           */
          public final Status getStatus(String status, Status dephault) {
              return (Status) this.getEnum(status, dephault);
          }
      }
  
      /**
       * Constructor Status
       * 
       * @param value 
       * @param name  
       */
      private Status(int value, String name) {
          super(type, value, name);
      }
  }
  
  
  
  1.16      +1 -1      ws-axis/java/src/org/apache/axis/enum/Enum.java
  
  Index: Enum.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/enum/Enum.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Enum.java	13 Aug 2003 19:08:23 -0000	1.15
  +++ Enum.java	22 Feb 2004 20:23:55 -0000	1.16
  @@ -135,7 +135,7 @@
               }
           }
           
  -        protected void setDefault(Enum dephault) {
  +        public void setDefault(Enum dephault) {
               this.dephault = dephault;
           }
           
  
  
  
  1.2       +1 -0      ws-axis/java/test/client/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/client/PackageTests.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PackageTests.java	28 Nov 2003 03:57:51 -0000	1.1
  +++ PackageTests.java	22 Feb 2004 20:23:55 -0000	1.2
  @@ -16,6 +16,7 @@
           TestSuite suite = new TestSuite("All Axis Call tests");
   
           suite.addTest(TestCall.suite());
  +        suite.addTest(TestAsyncCall.suite());
           return suite;
       }
   }
  
  
  
  1.1                  ws-axis/java/test/client/TestAsyncCall.java
  
  Index: TestAsyncCall.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package test.client;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.axis.client.Call;
  import org.apache.axis.client.async.AsyncCall;
  import org.apache.axis.client.async.IAsyncCallback;
  import org.apache.axis.client.async.IAsyncResult;
  import org.apache.axis.client.async.Status;
  
  import java.net.MalformedURLException;
  import java.net.URL;
  
  public class TestAsyncCall extends TestCase {
      public TestAsyncCall(String name) {
          super(name);
      }
  
      public static Test suite() {
          return new TestSuite(TestAsyncCall.class);
      }
  
      protected void setup() {
      }
  
      public void testAsyncPollWeatherService() throws MalformedURLException, InterruptedException
{
          Call call = new Call(new URL("http://live.capescience.com:80/ccx/GlobalWeather"));
          call.setUseSOAPAction(true);
          call.setSOAPActionURI("capeconnect:GlobalWeather:StationInfo#listCountries");
          call.setTimeout(new Integer(15 * 1000));
          call.setOperationName(new javax.xml.namespace.QName("capeconnect:GlobalWeather:StationInfo",
"listCountries"));
          AsyncCall ac = new AsyncCall(call);
          IAsyncResult result = ac.invoke(new Object[]{});
          System.out.println("STARTED");
          Status status = null;
          while ((status = result.getStatus()) == Status.NONE) {
              System.out.print('.');
              Thread.sleep(50);
          }
          System.out.println("FINISHED");
          if (status == Status.COMPLETED) {
              String[] c = (String[]) result.getResponse();
              System.out.println(c.length);
              for (int i = 0; i < c.length; i++) {
                  System.out.println(c[i]);
              }
          } else if (status == Status.EXCEPTION) {
              result.getException().printStackTrace();
          }
      }
  
      public void testAsyncCallbackWeatherService() throws MalformedURLException, InterruptedException
{
          final Call call = new Call(new URL("http://live.capescience.com:80/ccx/GlobalWeather"));
          call.setUseSOAPAction(true);
          call.setSOAPActionURI("capeconnect:GlobalWeather:StationInfo#listCountries");
          call.setTimeout(new Integer(15 * 1000));
          call.setOperationName(new javax.xml.namespace.QName("capeconnect:GlobalWeather:StationInfo",
"listCountries"));
          final AsyncCall ac = new AsyncCall(call, new IAsyncCallback() {
              public void onCompletion(IAsyncResult result) {
                  Status status = result.getStatus();
                  System.out.println(".....FINISHED");
                  if (status == Status.COMPLETED) {
                      String[] c = (String[]) result.getResponse();
                      System.out.println(c.length);
                      for (int i = 0; i < c.length; i++) {
                          System.out.println(c[i]);
                      }
                  } else if (status == Status.EXCEPTION) {
                      result.getException().printStackTrace();
                  }
                  synchronized (call) {
                      call.notifyAll();
                  }
              }
          });
          IAsyncResult result = ac.invoke(new Object[]{});
          System.out.println("STARTED....");
          synchronized (call) {
              call.wait(0);
          }
      }
  }
  
  
  

Mime
View raw message