summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-11-21 12:35:41 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-11-21 12:35:41 +0000
commiteaec6ebe25a05218e9041599812edc919a120514 (patch)
tree1f079beb2b8daa8bf4abe2b184b82f328382c13d
parent8af7a970664b2d912f88d4cf010a2bdbf76118ef (diff)
TUSCANY-3977: Commit patch from Anuj Bhatia to fix No way to configure wink timeout for binding.rest
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1204472 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java3
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java10
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java13
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessorTestCase.java3
4 files changed, 27 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java
index 5917d1f63e..9e16acc524 100644
--- a/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java
+++ b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java
@@ -36,5 +36,8 @@ public interface RESTBinding extends Binding {
public List<HTTPHeader> getHttpHeaders();
+ public int getReadTimeout();
+ public void setReadTimeout(int timeout);
+
public boolean isCORS();
}
diff --git a/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java
index 132d7227e7..f46bc2ef78 100644
--- a/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java
+++ b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java
@@ -42,6 +42,8 @@ class RESTBindingImpl implements RESTBinding {
private List<HTTPHeader> httpHeaders = new ArrayList<HTTPHeader>();
+ private int readTimeout = 60000;
+
private WireFormat requestWireFormat;
private WireFormat responseWireFormat;
private OperationSelector operationSelector;
@@ -112,4 +114,12 @@ class RESTBindingImpl implements RESTBinding {
public boolean isCORS() {
return true;
}
+
+ public int getReadTimeout() {
+ return readTimeout;
+ }
+
+ public void setReadTimeout(int readTimeout) {
+ this.readTimeout = readTimeout;
+ }
}
diff --git a/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java
index 81463b2889..8092d3e484 100644
--- a/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java
+++ b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java
@@ -33,6 +33,7 @@ import org.apache.tuscany.sca.assembly.WireFormat;
import org.apache.tuscany.sca.binding.rest.RESTBinding;
import org.apache.tuscany.sca.binding.rest.RESTBindingFactory;
import org.apache.tuscany.sca.common.http.HTTPHeader;
+import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
@@ -57,6 +58,7 @@ public class RESTBindingProcessor extends BaseStAXArtifactProcessor implements S
private static final String NAME = "name";
private static final String VALUE = "value";
private static final String URI = "uri";
+ private static final String READ_TIMEOUT = "readTimeout";
private RESTBindingFactory httpBindingFactory;
private StAXArtifactProcessor<Object> extensionProcessor;
@@ -81,7 +83,7 @@ public class RESTBindingProcessor extends BaseStAXArtifactProcessor implements S
RESTBinding restBinding = httpBindingFactory.createRESTBinding();
/**
- * <tuscany:binding.rest uri="http://localhost:8085/Customer">
+ * <tuscany:binding.rest uri="http://localhost:8085/Customer" readTimeout="60000">
* <tuscany:wireFormat.xml />
* <tuscany:operationSelector.jaxrs />
* <tuscany:http-headers>
@@ -113,6 +115,11 @@ public class RESTBindingProcessor extends BaseStAXArtifactProcessor implements S
if (uri != null) {
restBinding.setURI(uri);
}
+
+ String readTimeout = getReadTimeoutString(reader, READ_TIMEOUT);
+ if (readTimeout != null) {
+ restBinding.setReadTimeout(Integer.valueOf(readTimeout));
+ }
break;
} else if (HEADERS_QNAME.equals(elementName)) {
@@ -189,6 +196,10 @@ public class RESTBindingProcessor extends BaseStAXArtifactProcessor implements S
return restBinding;
}
+ private String getReadTimeoutString(XMLStreamReader reader, String readTimeout) {
+ return StAXHelper.getAttributeAsString(reader, readTimeout);
+ }
+
public void write(RESTBinding restBinding, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
writeStart(writer, RESTBinding.TYPE.getNamespaceURI(), RESTBinding.TYPE.getLocalPart());
diff --git a/sca-java-2.x/trunk/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessorTestCase.java b/sca-java-2.x/trunk/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessorTestCase.java
index 55a539044d..d2bc2e0e76 100644
--- a/sca-java-2.x/trunk/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessorTestCase.java
+++ b/sca-java-2.x/trunk/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessorTestCase.java
@@ -48,7 +48,7 @@ public class RESTBindingProcessorTestCase {
+ " <component name=\"CustomerService\">"
+ " <implementation.java class=\"services.customer.CustomerServiceImpl\"/>"
+ " <service name=\"CustomerService\">"
- + " <tuscany:binding.rest uri=\"http://localhost:8085/Customer\">"
+ + " <tuscany:binding.rest uri=\"http://localhost:8085/Customer\" readTimeout=\"30000\">"
+ " <tuscany:wireFormat.xml />"
+ " <tuscany:operationSelector.jaxrs />"
+ " <tuscany:http-headers>"
@@ -86,6 +86,7 @@ public class RESTBindingProcessorTestCase {
RESTBinding binding = (RESTBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
Assert.assertNotNull(binding);
+ Assert.assertEquals(30000, binding.getReadTimeout());
Assert.assertEquals(2, binding.getHttpHeaders().size());
Assert.assertEquals("Cache-Control", binding.getHttpHeaders().get(0).getName());
Assert.assertEquals("no-cache", binding.getHttpHeaders().get(0).getValue());