diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-rest/src/main/java')
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()); |