1 16 17 package org.apache.axis.client.async; 18 19 import javax.xml.namespace.QName ; 20 21 26 public class AsyncResult implements IAsyncResult, Runnable { 27 28 31 private Thread thread = null; 32 33 36 private Object response = null; 37 38 41 private Throwable exception = null; 42 43 46 private AsyncCall ac = null; 47 48 51 private QName opName = null; 52 53 56 private Object [] params = null; 57 58 61 private Status status = Status.NONE; 62 63 70 public AsyncResult(AsyncCall ac, QName opName, Object [] params) { 71 this.ac = ac; 72 this.opName = opName; 73 this.params = params; 74 75 if (opName == null) { 76 this.opName = ac.getCall().getOperationName(); 77 } 78 79 thread = new Thread (this); 80 thread.setDaemon(true); 81 thread.start(); 82 } 83 84 87 public void abort() { 88 thread.interrupt(); 89 status = Status.INTERRUPTED; 90 } 91 92 97 public Status getStatus() { 98 return status; 99 } 100 101 107 public void waitFor(long timeout) throws InterruptedException { 108 thread.wait(timeout); 109 } 110 111 116 public Object getResponse() { 117 return response; 118 } 119 120 125 public Throwable getException() { 126 return exception; 127 } 128 129 132 public void run() { 133 try { 134 response = ac.getCall().invoke(opName, params); 135 status = Status.COMPLETED; 136 } catch (Throwable e) { 137 exception = e; 138 status = Status.EXCEPTION; 139 } finally { 140 IAsyncCallback callback = ac.getCallback(); 141 if (callback != null) { 142 callback.onCompletion(this); 143 } 144 } 145 } 146 } 147 | Popular Tags |