Author: chris.laprun(a)jboss.com
Date: 2010-01-05 17:23:20 -0500 (Tue, 05 Jan 2010)
New Revision: 1167
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EndpointConfigurationInfo.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/SOAPServiceFactory.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceFactory.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceWrapper.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/BehaviorBackedServiceFactory.java
Log:
- Added possibility to change the timeout for WS operations on a per ServiceFactory basis.
Will allow setting this in the admin GUI.
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EndpointConfigurationInfo.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EndpointConfigurationInfo.java 2010-01-05
19:28:49 UTC (rev 1166)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EndpointConfigurationInfo.java 2010-01-05
22:23:20 UTC (rev 1167)
@@ -173,4 +173,20 @@
return remoteHostAddress;
}
+
+ /**
+ * Number of milliseconds before a WS operation is considered as having timed out.
+ *
+ * @param msBeforeTimeOut number of milliseconds to wait for a WS operation to return
before timing out. Will be set
+ * to {@link ServiceFactory#DEFAULT_TIMEOUT_MS} if negative.
+ */
+ public void setWSOperationTimeOut(int msBeforeTimeOut)
+ {
+ serviceFactory.setWSOperationTimeOut(msBeforeTimeOut);
+ }
+
+ public int getWSOperationTimeOut()
+ {
+ return serviceFactory.getWSOperationTimeOut();
+ }
}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/SOAPServiceFactory.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/SOAPServiceFactory.java 2010-01-05
19:28:49 UTC (rev 1166)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/SOAPServiceFactory.java 2010-01-05
22:23:20 UTC (rev 1167)
@@ -61,6 +61,7 @@
private String registrationURL;
private boolean failed;
private boolean available;
+ private int msBeforeTimeOut;
public <T> T getService(Class<T> clazz) throws Exception
{
@@ -205,6 +206,21 @@
this.available = available;
}
+ public void setWSOperationTimeOut(int msBeforeTimeOut)
+ {
+ if (msBeforeTimeOut < 0)
+ {
+ msBeforeTimeOut = DEFAULT_TIMEOUT_MS;
+ }
+
+ this.msBeforeTimeOut = msBeforeTimeOut;
+ }
+
+ public int getWSOperationTimeOut()
+ {
+ return msBeforeTimeOut;
+ }
+
public String getWsdlDefinitionURL()
{
return wsdlDefinitionURL;
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceFactory.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceFactory.java 2010-01-05
19:28:49 UTC (rev 1166)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceFactory.java 2010-01-05
22:23:20 UTC (rev 1167)
@@ -30,6 +30,8 @@
*/
public interface ServiceFactory
{
+ int DEFAULT_TIMEOUT_MS = 10000;
+
<T> T getService(Class<T> clazz) throws Exception;
/**
@@ -73,4 +75,14 @@
void setWsdlDefinitionURL(String wsdlDefinitionURL);
String getWsdlDefinitionURL();
+
+ /**
+ * Number of milliseconds before a WS operation is considered as having timed out.
+ *
+ * @param msBeforeTimeOut number of milliseconds to wait for a WS operation to return
before timing out. Will be set
+ * to {@link #DEFAULT_TIMEOUT_MS} if negative.
+ */
+ void setWSOperationTimeOut(int msBeforeTimeOut);
+
+ int getWSOperationTimeOut();
}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceWrapper.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceWrapper.java 2010-01-05
19:28:49 UTC (rev 1166)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceWrapper.java 2010-01-05
22:23:20 UTC (rev 1167)
@@ -40,7 +40,6 @@
{
protected T service;
protected ManageableServiceFactory parentFactory;
- private static final int TIMEOUT_MS = 10 * 1000; //todo: expose timeout so that it can
be changed from the GUI
/**
* HTTP request timeout property. JAX-WS doesn't standardize that value, so needs
to be adapted per used
@@ -61,7 +60,7 @@
// set timeout properties for different WS stacks
BindingProvider bindingProvider = (BindingProvider)service;
- setTimeout(bindingProvider);
+ setTimeout(bindingProvider, parentFactory);
Class tClass =
(Class)((ParameterizedType)getClass().getGenericSuperclass()).getActualTypeArguments()[0];
@@ -76,18 +75,18 @@
this.parentFactory = parentFactory;
}
- private static void setTimeout(BindingProvider bindingProvider)
+ private static void setTimeout(BindingProvider bindingProvider,
ManageableServiceFactory parentFactory)
{
Map<String, Object> requestContext = bindingProvider.getRequestContext();
- requestContext.put(JBOSS_WS_TIMEOUT, TIMEOUT_MS);
- requestContext.put(SUN_WS_TIMEOUT, TIMEOUT_MS);
- requestContext.put(IBM_WS_TIMEOUT, TIMEOUT_MS);
+ requestContext.put(JBOSS_WS_TIMEOUT, parentFactory.getWSOperationTimeOut());
+ requestContext.put(SUN_WS_TIMEOUT, parentFactory.getWSOperationTimeOut());
+ requestContext.put(IBM_WS_TIMEOUT, parentFactory.getWSOperationTimeOut());
}
public static <T> T getServiceWrapper(Class<T> expectedServiceInterface,
Object service, ManageableServiceFactory parentFactory)
{
// for now, only set timeouts
- setTimeout((BindingProvider)service);
+ setTimeout((BindingProvider)service, parentFactory);
return expectedServiceInterface.cast(service);
}
Modified:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/BehaviorBackedServiceFactory.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/BehaviorBackedServiceFactory.java 2010-01-05
19:28:49 UTC (rev 1166)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/BehaviorBackedServiceFactory.java 2010-01-05
22:23:20 UTC (rev 1167)
@@ -64,6 +64,7 @@
private boolean initialized = false;
private String wsdl = DEFAULT_WSDL_URL;
public static final String DEFAULT_WSDL_URL = "http://example.com?wsdl";
+ private int timeout;
public BehaviorBackedServiceFactory()
@@ -123,6 +124,21 @@
// do nothing
}
+ public void setWSOperationTimeOut(int msBeforeTimeOut)
+ {
+ if (msBeforeTimeOut < 0)
+ {
+ msBeforeTimeOut = DEFAULT_TIMEOUT_MS;
+ }
+
+ timeout = msBeforeTimeOut;
+ }
+
+ public int getWSOperationTimeOut()
+ {
+ return timeout;
+ }
+
public String getServiceDescriptionURL()
{
return SD_URL;
Show replies by date