summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2011-11-11 00:53:16 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2011-11-11 00:53:16 +0000
commitcd07713f408a9edc820fb70a7dead012ee1ff899 (patch)
treebaea598f776a47141d9afc49f453200ba1f947f2 /sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
parentc607b0cf671eda11eff333748e4ce3a75ce941d1 (diff)
Refactoring binding http model to bring back support for servlet based resources, and making rpc style it's own operationSelector
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1200669 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java')
-rw-r--r--sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java93
1 files changed, 33 insertions, 60 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
index 3a3436d101..f06dad2a9b 100644
--- a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
@@ -22,8 +22,9 @@ package org.apache.tuscany.sca.binding.http.provider;
import javax.servlet.Servlet;
import org.apache.tuscany.sca.binding.http.HTTPBinding;
-import org.apache.tuscany.sca.binding.http.HTTPDefaultOperationSelector;
-import org.apache.tuscany.sca.binding.http.HTTPDefaultWireFormat;
+import org.apache.tuscany.sca.binding.http.operationselector.HTTPDefaultOperationSelector;
+import org.apache.tuscany.sca.binding.http.operationselector.HTTPRPCOperationSelector;
+import org.apache.tuscany.sca.binding.http.wireformat.HTTPDefaultWireFormat;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
@@ -56,7 +57,6 @@ public class HTTPServiceBindingProvider implements EndpointProvider {
private ServletHost servletHost;
private String servletMapping;
private InterfaceContract interfaceContract;
- private boolean widget;
private HTTPBindingListenerServlet bindingListenerServlet;
@@ -67,19 +67,18 @@ public class HTTPServiceBindingProvider implements EndpointProvider {
this.endpoint = endpoint;
this.binding = (HTTPBinding)endpoint.getBinding();
- this.widget = "Widget".equals(binding.getName());
this.extensionPoints = extensionPoints;
this.messageFactory = messageFactory;
this.servletHost = servletHost;
- if (binding.getOperationSelector() == null && !widget) {
+ if (binding.getOperationSelector() == null) {
binding.setOperationSelector(new HTTPDefaultOperationSelector());
}
- if (binding.getRequestWireFormat() == null && !widget) {
+ if (binding.getRequestWireFormat() == null) {
binding.setRequestWireFormat(new HTTPDefaultWireFormat());
}
- if (binding.getResponseWireFormat() == null && !widget) {
+ if (binding.getResponseWireFormat() == null) {
binding.setResponseWireFormat(new HTTPDefaultWireFormat());
}
@@ -123,63 +122,40 @@ public class HTTPServiceBindingProvider implements EndpointProvider {
}
public void start() {
- if (widget) {
- start1x();
- } else {
- String deployedURI = servletHost.addServletMapping(servletMapping, new HTTPBindingServiceServlet(endpoint, messageFactory));
- endpoint.setDeployedURI(deployedURI);
+
+ /**
+ * Consider three scenarios here :
+ * - Default servlet using service level operation
+ * - Default servlet using GET, PUT, POST, DELETE operations mapped to interface names with same name
+ * - RPC over HTTP like : http://localhost:8080/HelloworldComponent/Helloworld/sayHello?name=Petra
+ */
+ if (binding.getOperationSelector() == null || binding.getRequestWireFormat() == null || binding.getResponseWireFormat() == null) {
+ throw new IllegalStateException("Binding operation selector and/or wire formats not properly setup.");
}
- }
-
- public void start1x() {
- // Get the invokers for the supported operations
+
+ InvocationChain bindingChain = endpoint.getBindingInvocationChain();
+
Servlet servlet = null;
- bindingListenerServlet = new HTTPBindingListenerServlet(binding, messageFactory );
+ Invoker bindingInvoker = bindingChain.getHeadInvoker();
+ bindingListenerServlet = new HTTPBindingListenerServlet(binding, messageFactory);
for (InvocationChain invocationChain : endpoint.getInvocationChains()) {
+
Operation operation = invocationChain.getTargetOperation();
+ Invoker serviceInvoker = invocationChain.getHeadInvoker();
String operationName = operation.getName();
- if (operationName.equals("get")) {
- Invoker getInvoker = invocationChain.getHeadInvoker();
- bindingListenerServlet.setGetInvoker(getInvoker);
- servlet = bindingListenerServlet;
- } else if (operationName.equals("conditionalGet")) {
- Invoker conditionalGetInvoker = invocationChain.getHeadInvoker();
- bindingListenerServlet.setConditionalGetInvoker(conditionalGetInvoker);
- servlet = bindingListenerServlet;
- } else if (operationName.equals("delete")) {
- Invoker deleteInvoker = invocationChain.getHeadInvoker();
- bindingListenerServlet.setDeleteInvoker(deleteInvoker);
- servlet = bindingListenerServlet;
- } else if (operationName.equals("conditionalDelete")) {
- Invoker conditionalDeleteInvoker = invocationChain.getHeadInvoker();
- bindingListenerServlet.setConditionalDeleteInvoker(conditionalDeleteInvoker);
- servlet = bindingListenerServlet;
- } else if (operationName.equals("put")) {
- Invoker putInvoker = invocationChain.getHeadInvoker();
- bindingListenerServlet.setPutInvoker(putInvoker);
- servlet = bindingListenerServlet;
- } else if (operationName.equals("conditionalPut")) {
- Invoker conditionalPutInvoker = invocationChain.getHeadInvoker();
- bindingListenerServlet.setConditionalPutInvoker(conditionalPutInvoker);
- servlet = bindingListenerServlet;
- } else if (operationName.equals("post")) {
- Invoker postInvoker = invocationChain.getHeadInvoker();
- bindingListenerServlet.setPostInvoker(postInvoker);
- servlet = bindingListenerServlet;
- } else if (operationName.equals("conditionalPost")) {
- Invoker conditionalPostInvoker = invocationChain.getHeadInvoker();
- bindingListenerServlet.setConditionalPostInvoker(conditionalPostInvoker);
- servlet = bindingListenerServlet;
- } else if (operationName.equals("service")) {
- Invoker serviceInvoker = invocationChain.getHeadInvoker();
-// servlet = new HTTPServiceListenerServlet(binding, serviceInvoker, messageFactory);
+
+ /*
+ if (operationName.equals("service")) {
+ servlet = new HTTPBindingListenerServlet(binding, messageFactory);
break;
- }
- }
- if (servlet == null) {
- throw new IllegalStateException("No get or service method found on the service");
+ } else {
+ */
+ servlet = new HTTPBindingServiceServlet(endpoint, messageFactory);
+ /*
+ }
+ */
}
-
+
// Create our HTTP service listener Servlet and register it with the
// Servlet host
servletMapping = binding.getURI();
@@ -210,9 +186,6 @@ public class HTTPServiceBindingProvider implements EndpointProvider {
* Add specific http interceptor to invocation chain
*/
public void configure() {
-
- if (widget) return;
-
InvocationChain bindingChain = endpoint.getBindingInvocationChain();
if(osProvider != null) {