diff options
Diffstat (limited to '')
3 files changed, 34 insertions, 19 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 6ef5292281..2326848026 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 @@ -53,4 +53,11 @@ public interface RESTBinding extends Binding { * @return */ public boolean isCORS(); + + /** + * Enable/Disable CORS support for the REST binding + * @param isCors + * @return + */ + public void setCORS(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 f46bc2ef78..df6a1b12dd 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 @@ -40,9 +40,10 @@ class RESTBindingImpl implements RESTBinding { private String name; private String uri; - private List<HTTPHeader> httpHeaders = new ArrayList<HTTPHeader>(); - private int readTimeout = 60000; + private boolean isCORS = false; + + private List<HTTPHeader> httpHeaders = new ArrayList<HTTPHeader>(); private WireFormat requestWireFormat; private WireFormat responseWireFormat; @@ -68,6 +69,22 @@ class RESTBindingImpl implements RESTBinding { this.uri = uri; } + public int getReadTimeout() { + return readTimeout; + } + + public void setReadTimeout(int readTimeout) { + this.readTimeout = readTimeout; + } + + public boolean isCORS() { + return isCORS; + } + + public void setCORS(boolean isCORS) { + this.isCORS = isCORS; + } + public List<HTTPHeader> getHttpHeaders() { return this.httpHeaders; } @@ -110,16 +127,4 @@ class RESTBindingImpl implements RESTBinding { public Object clone() throws CloneNotSupportedException { return super.clone(); } - - 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 da76b550a5..e2f3ced71d 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 @@ -73,6 +73,7 @@ public class RESTBindingProcessor extends BaseStAXArtifactProcessor implements S private static final String VALUE = "value"; private static final String URI = "uri"; private static final String READ_TIMEOUT = "readTimeout"; + private static final String CORS ="isCORS"; private RESTBindingFactory restBindingFactory; private JSONWireFormatFactory jsonWireFormatFactory; @@ -140,10 +141,16 @@ public class RESTBindingProcessor extends BaseStAXArtifactProcessor implements S restBinding.setURI(uri); } - String readTimeout = getReadTimeoutString(reader, READ_TIMEOUT); + String readTimeout = getString(reader, READ_TIMEOUT); if (readTimeout != null) { restBinding.setReadTimeout(Integer.valueOf(readTimeout)); } + + Boolean isCORS = getBoolean(reader, CORS); + if(isCORS != null) { + restBinding.setCORS(isCORS); + } + break; } else if (HEADERS_QNAME.equals(elementName)) { @@ -265,10 +272,6 @@ public class RESTBindingProcessor extends BaseStAXArtifactProcessor implements S } - private String getReadTimeoutString(XMLStreamReader reader, String readTimeout) { - return StAXHelper.getAttributeAsString(reader, readTimeout); - } - private Object readWireFormatAndOperationSelectorExtensions(XMLStreamReader reader) throws XMLStreamException { QName elementName = reader.getName(); |