summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-rest
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2012-05-23 17:12:46 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2012-05-23 17:12:46 +0000
commitc918a7b508eb6221f931d8d6307b3c839d5ab874 (patch)
treee161f5cc81ff0e66f6d753b68e4e036628faf13d /sca-java-2.x/trunk/modules/binding-rest
parent98c732a3f4df85e9dba671af07b749e5d180b569 (diff)
Add CORS support for servlet based impl with REST binding
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1341952 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java4
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceListenerServlet.java4
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java1
3 files changed, 9 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java
index e0a681ed36..f6d5778aba 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java
@@ -39,6 +39,7 @@ import org.apache.tuscany.sca.common.http.HTTPCacheContext;
import org.apache.tuscany.sca.common.http.HTTPContentTypeMapper;
import org.apache.tuscany.sca.common.http.HTTPContext;
import org.apache.tuscany.sca.common.http.HTTPHeader;
+import org.apache.tuscany.sca.common.http.cors.CORSHeaderProcessor;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.MessageFactory;
@@ -78,6 +79,9 @@ public class RESTBindingListenerServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ if (binding.isCORS()) {
+ CORSHeaderProcessor.processCORS(binding.getCORSConfiguration(), request, response);
+ }
if( binding.getOperationSelector() != null || binding.getRequestWireFormat() != null) {
HTTPContext bindingContext = new HTTPContext();
bindingContext.setHttpRequest(request);
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceListenerServlet.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceListenerServlet.java
index 1dac8a2c9a..c8b0bbf595 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceListenerServlet.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceListenerServlet.java
@@ -36,6 +36,7 @@ import org.apache.tuscany.sca.binding.rest.RESTBinding;
import org.apache.tuscany.sca.common.http.HTTPCacheContext;
import org.apache.tuscany.sca.common.http.HTTPContext;
import org.apache.tuscany.sca.common.http.HTTPHeader;
+import org.apache.tuscany.sca.common.http.cors.CORSHeaderProcessor;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.MessageFactory;
@@ -82,6 +83,9 @@ public class RESTServiceListenerServlet extends HttpServlet implements Servlet {
@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ if (binding.isCORS()) {
+ CORSHeaderProcessor.processCORS(binding.getCORSConfiguration(), request, response);
+ }
HTTPContext bindingContext = new HTTPContext();
bindingContext.setHttpRequest(request);
bindingContext.setHttpResponse(response);
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 da0e1ece06..0e8b352a2a 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
@@ -205,6 +205,7 @@ public class RESTBindingProcessor extends BaseStAXArtifactProcessor implements S
restBinding.setResponseWireFormat((WireFormat)extension);
} else if(extension instanceof OperationSelector) {
restBinding.setOperationSelector((OperationSelector)extension);
+ restBinding.setCORS(true);
}
}
break;