[jbossws-commits] JBossWS SVN: r12973 - in stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core: client/transport and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Wed Sep 15 06:32:31 EDT 2010


Author: jim.ma
Date: 2010-09-15 06:32:31 -0400 (Wed, 15 Sep 2010)
New Revision: 12973

Modified:
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/StubExt.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyClient.java
Log:
[JBWS-3114]:Added new connectionTimeout and recevieTimeout configuration

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/StubExt.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/StubExt.java	2010-09-15 10:31:19 UTC (rev 12972)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/StubExt.java	2010-09-15 10:32:31 UTC (rev 12973)
@@ -71,6 +71,16 @@
    static final String PROPERTY_MTOM_ENABLED= "org.jboss.ws.mtom.enabled";
    /** HTTP chunk size */
    static final String PROPERTY_CHUNKED_ENCODING_SIZE = "http://org.jboss.ws/http#chunksize";
+   
+   //New added property to provide stack agnostic timeout configuration(JBWS-3114)
+   /** Client ConnectionTimeout property: javax.xml.ws.client.connectionTimeout */
+   static final String PROPERTY_CONNECTION_TIMEOUT = "javax.xml.ws.client.connectionTimeout";
+   
+   /** Client ReceiveTimeout property: javax.xml.ws.client.receiveTimeout */
+   static final String PROPERTY_RECEIVE_TIMEOUT = "javax.xml.ws.client.receiveTimeout";
+   
+   
+   
 
    /**
     * Add a header that is not bound to an input parameter.

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyClient.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyClient.java	2010-09-15 10:31:19 UTC (rev 12972)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyClient.java	2010-09-15 10:32:31 UTC (rev 12973)
@@ -84,6 +84,8 @@
    private Marshaller marshaller;
    private UnMarshaller unmarshaller;
    private Long timeout;
+   private Long connectionTimeout;
+   private Long receiveTimeout;
    private static final int DEFAULT_CHUNK_SIZE = 1024;
    //We always use chunked transfer encoding unless explicitly disabled by user 
    private Integer chunkSize = new Integer(DEFAULT_CHUNK_SIZE);
@@ -153,7 +155,20 @@
       try
       {
          setActualTimeout(callProps);
-         channel = transport.getChannel(timeout);
+         //JBWS-3114:Provide the new connection timeout configuration
+         if (callProps.containsKey(StubExt.PROPERTY_CONNECTION_TIMEOUT))
+         {
+            connectionTimeout = new Long(callProps.get(StubExt.PROPERTY_CONNECTION_TIMEOUT).toString());
+         }
+         else
+         {
+            if (timeout != null)
+            {
+               connectionTimeout = timeout;
+            }
+         }
+       
+         channel = transport.getChannel(connectionTimeout);
          
          WSResponseHandler responseHandler = new WSResponseHandler();
          NettyHelper.setResponseHandler(channel, responseHandler);
@@ -178,9 +193,21 @@
          //Get the response
          Future<Result> futureResult = responseHandler.getFutureResult();
          Result result = null;
+         if (callProps.containsKey(StubExt.PROPERTY_RECEIVE_TIMEOUT))
+         {
+            receiveTimeout = new Long(callProps.get(StubExt.PROPERTY_RECEIVE_TIMEOUT).toString());
+         }
+         else
+         {
+            if (timeout != null)
+            {
+               receiveTimeout = timeout;
+            }
+         }
          try
          {
-        	 result = timeout == null ? futureResult.get() : futureResult.get(timeout, TimeUnit.MILLISECONDS);
+            result = receiveTimeout == null ? futureResult.get() : futureResult.get(receiveTimeout,
+                  TimeUnit.MILLISECONDS);
          }
          catch (ExecutionException ee)
          {
@@ -188,6 +215,10 @@
         	 Throwable t = ee.getCause();
         	 throw t != null ? t : ee;
          }
+	 catch (TimeoutException te) 
+	 {
+	    throw new WSTimeoutException("Receive timeout", receiveTimeout == null ? -1 : receiveTimeout);
+	 }
          resHeaders = result.getResponseHeaders();
          resMetadata = result.getMetadata();
          Object resMessage = oneway ? null : unmarshaller.read(result.getResponse(), resMetadata, resHeaders);
@@ -212,14 +243,14 @@
          transport.end();
          throw ce;
       }
+      catch (TimeoutException te) 
+      {
+	 throw new WSTimeoutException("Connection timeout", connectionTimeout == null ? -1 : connectionTimeout);
+      }
       catch (IOException ioe)
       {
          throw ioe;
       }
-      catch (TimeoutException te)
-      {
-         throw new WSTimeoutException(te.getMessage(), timeout);
-      }
       catch (WSTimeoutException toe)
       {
          throw toe;



More information about the jbossws-commits mailing list