diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-11-21 12:35:41 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-11-21 12:35:41 +0000 |
commit | eaec6ebe25a05218e9041599812edc919a120514 (patch) | |
tree | 1f079beb2b8daa8bf4abe2b184b82f328382c13d /sca-java-2.x/trunk/modules/binding-rest/src/main/java | |
parent | 8af7a970664b2d912f88d4cf010a2bdbf76118ef (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
Diffstat (limited to '')
3 files changed, 25 insertions, 1 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()); |