/** * Stores a given Throwable in this AsyncFaultWrapper * If the supplied Throwable itself contains an embedded Throwable ("cause"), this is recursively * wrapped by a nested AsyncFaultWrapper * @param e - the Throwable */ public void storeFault( Throwable e ) { setFaultClassName( e.getClass().getCanonicalName() ); setFaultMessage( e.getMessage() ); Throwable cause = e.getCause(); if( cause != null ) setContainedFault( new AsyncFaultWrapper( cause ) ); }
/** * Constructor which creates an AsyncFaultWrapper which wraps the supplied Throwable * @param e - a Throwable which is wrapped by this AsyncFaultWrapper */ public AsyncFaultWrapper( Throwable e ) { super(); storeFault( e ); }
return (Throwable) cons.newInstance(faultMessage, getContainedFault().retrieveFault()); } else { try {
/** * Send a Fault. Must only be invoked once for this ResponseDispatch object * @param e - the Fault to send * @throws IllegalStateException if either the sendResponse method or the sendFault method have been called previously */ public void sendFault(Throwable e) { if( sendOK() ) { lock.lock(); try { fault = e; completed.signalAll(); } finally { lock.unlock(); } // end try } else { throw new IllegalStateException("sendResponse() or sendFault() has been called previously"); } // end if // Use response invoker if present if( respInvoker != null ) { //respInvoker.invokeAsyncResponse(new AsyncFaultWrapper(e)); respInvoker.invokeAsyncResponse(e, null); return; } // end if // Now dispatch the response to the callback... AsyncResponseHandler<T> handler = (AsyncResponseHandler<T>) callbackRef.getService(); setResponseHeaders(); handler.setWrappedFault(new AsyncFaultWrapper(e)); } // end method sendFault
/** * Async process completed with a wrapped Fault. Must only be invoked once. * @param w - the wrapped Fault to send * @throws IllegalStateException if either the setResponse method or the setFault method have been called previously */ public void setWrappedFault(AsyncFaultWrapper w) { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); Throwable e; try { // Set the TCCL to the classloader of the business interface Thread.currentThread().setContextClassLoader(this.getBusinessInterface().getClassLoader()); e = w.retrieveFault(); } finally { Thread.currentThread().setContextClassLoader(tccl); } // end try if( e == null ) throw new IllegalArgumentException("AsyncFaultWrapper did not return an Exception"); setFault( e ); } // end method setFault( AsyncFaultWrapper )
args = new AsyncFaultWrapper( (Throwable) args );