You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ng...@apache.org on 2007/01/22 00:47:30 UTC
svn commit: r498492 - in
/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async:
AsyncResponse.java AsyncUtils.java CallbackFuture.java
Author: ngallardo
Date: Sun Jan 21 15:47:29 2007
New Revision: 498492
URL: http://svn.apache.org/viewvc?view=rev&rev=498492
Log:
Exceptions that occur as a result of the unmarhsalling the async response. This fixes
that along with adding some additional debug.
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java?view=diff&rev=498492&r1=498491&r2=498492
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java Sun Jan 21 15:47:29 2007
@@ -26,7 +26,6 @@
import java.util.concurrent.TimeoutException;
import javax.xml.ws.Response;
-import javax.xml.ws.WebServiceException;
import org.apache.axiom.om.OMElement;
import org.apache.axis2.jaxws.ExceptionFactory;
@@ -46,9 +45,9 @@
public class AsyncResponse implements Response {
private static final Log log = LogFactory.getLog(AsyncResponse.class);
+ private static final boolean debug = log.isDebugEnabled();
private boolean cancelled;
- private Object responseObj;
private MessageContext response;
private Map<String, Object> responseContext;
private Throwable fault;
@@ -59,13 +58,30 @@
}
protected void onError(Throwable t) {
+ if (debug) {
+ log.debug("AsyncResponse received a fault. Counting down latch.");
+ log.debug("Fault type = " + t.getClass());
+ }
+
fault = t;
latch.countDown();
+
+ if (debug) {
+ log.debug("New latch count = [" + latch.getCount() + "]");
+ }
}
protected void onComplete(MessageContext mc) {
+ if (debug) {
+ log.debug("AsyncResponse received a MessageContext. Counting down latch.");
+ }
+
response = mc;
latch.countDown();
+
+ if (debug) {
+ log.debug("New latch count = [" + latch.getCount() + "]");
+ }
}
//-------------------------------------
@@ -91,48 +107,21 @@
public Object get() throws InterruptedException, ExecutionException {
// Wait for the response to come back
- latch.await();
-
- if (hasFault()) {
- throw new ExecutionException(ExceptionFactory.makeWebServiceException(fault));
- }
- if (response == null) {
- throw new ExecutionException(ExceptionFactory.makeWebServiceException("null response"));
+ if (debug) {
+ log.debug("Waiting for async response delivery.");
}
+ latch.await();
- // TODO: Check the type of the object to make sure it corresponds with
- // the parameterized generic type.
- if (responseObj == null) {
- if (log.isDebugEnabled()) {
- log.debug("Demarshalling the async response message");
- }
- responseObj = getResponseValueObject(response);
- }
-
- return responseObj;
+ Object obj = processAsyncResponse(response);
+ return obj;
}
public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
// Wait for the response to come back
latch.await(timeout, unit);
- if (hasFault()) {
- throw new ExecutionException(ExceptionFactory.makeWebServiceException(fault));
- }
- if (response == null) {
- throw new ExecutionException(ExceptionFactory.makeWebServiceException("null response"));
- }
-
- // TODO: Check the type of the object to make sure it corresponds with
- // the parameterized generic type.
- if (responseObj == null) {
- if (log.isDebugEnabled()) {
- log.debug("Demarshalling the async response message");
- }
- responseObj = getResponseValueObject(response);
- }
-
- return responseObj;
+ Object obj = processAsyncResponse(response);
+ return obj;
}
public boolean isCancelled() {
@@ -155,6 +144,37 @@
return true;
else
return false;
+ }
+
+ private Object processAsyncResponse(MessageContext ctx) throws ExecutionException {
+ if (hasFault()) {
+ throw new ExecutionException(ExceptionFactory.makeWebServiceException(fault));
+ }
+ if (ctx == null) {
+ throw new ExecutionException(ExceptionFactory.makeWebServiceException("null response"));
+ }
+
+ // TODO: Check the type of the object to make sure it corresponds with
+ // the parameterized generic type.
+ Object obj = null;
+ try {
+ if (debug) {
+ log.debug("Unmarshalling the async response message.");
+ }
+ obj = getResponseValueObject(ctx);
+ }
+ catch (Throwable t) {
+ if (debug) {
+ log.debug("An error occurred while processing the response");
+ }
+ throw new ExecutionException(ExceptionFactory.makeWebServiceException(t));
+ }
+
+ if (debug && obj != null) {
+ log.debug("Unmarshalled response object of type: " + obj.getClass());
+ }
+
+ return obj;
}
/**
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java?view=diff&rev=498492&r1=498491&r2=498492
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java Sun Jan 21 15:47:29 2007
@@ -31,9 +31,9 @@
public class AsyncUtils {
private static final Log log = LogFactory.getLog(AsyncUtils.class);
+ private static final boolean debug = log.isDebugEnabled();
public static MessageContext createMessageContext(AsyncResult result) throws WebServiceException {
- boolean debug = log.isDebugEnabled();
MessageContext response = null;
if (debug) {
@@ -54,7 +54,7 @@
log.debug("An error occurred in the ThreadContextMigratorUtil " + t);
log.debug("...caused by " + t.getCause());
}
- ExceptionFactory.makeWebServiceException(t);
+ throw ExceptionFactory.makeWebServiceException(t);
}
return response;
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=498492&r1=498491&r2=498492
==============================================================================
--- 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 Sun Jan 21 15:47:29 2007
@@ -43,6 +43,7 @@
public class CallbackFuture extends Callback {
private static final Log log = LogFactory.getLog(CallbackFuture.class);
+ private static final boolean debug = log.isDebugEnabled();
private CallbackFutureTask cft;
private Executor executor;
@@ -61,9 +62,8 @@
@Override
public void onComplete(AsyncResult result) {
- boolean debug = log.isDebugEnabled();
if (debug) {
- log.debug("JAX-WS async response listener received the response");
+ log.debug("JAX-WS received the async response");
}
MessageContext response = null;
@@ -108,6 +108,7 @@
class CallbackFutureTask implements Callable {
private static final Log log = LogFactory.getLog(CallbackFutureTask.class);
+ private static final boolean debug = log.isDebugEnabled();
AsyncResponse response;
MessageContext responseMsgCtx;
@@ -136,10 +137,20 @@
response.onError(error);
}
- if (log.isDebugEnabled()) {
- log.debug("Calling JAX-WS AsyncHandler with the Response object");
+ try {
+ if (debug) {
+ log.debug("Calling JAX-WS AsyncHandler with the Response object");
+ log.debug("AyncHandler class: " + handler.getClass());
+ }
+ handler.handleResponse(response);
+ }
+ catch (Throwable t) {
+ if (debug) {
+ log.debug("An error occured while invoking the callback object.");
+ log.debug("Error: " + t.getMessage());
+ }
}
- handler.handleResponse(response);
+
return null;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org