summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-05-05 07:19:53 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-05-05 07:19:53 +0000
commit841b4c7adf6c13158b17909b8208c59da793e376 (patch)
treec14f515779e953d6774524b6640a1993224c191e
parent7f7b5af5b56186445065f694d68bd2726e997ca3 (diff)
TUSCANY-2968 - Discovering and adding wire format and operation selector interceptors via extension point, but inside binding provider
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@771600 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory2
-rw-r--r--branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java5
-rw-r--r--branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPRRBListenerServlet.java66
-rw-r--r--branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java53
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java2
5 files changed, 117 insertions, 11 deletions
diff --git a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory
index 9bf5fe9ad7..61ee00271b 100644
--- a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory
+++ b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory
@@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.
-org.apache.tuscany.sca.binding.http.operationselector.jsonrpc.provider.JSONRPCOperationSelectorPropProviderFactory;model=org.apache.tuscany.sca.binding.http.operationselector.jsonrpc.JSONRPCOperationSelector
+org.apache.tuscany.sca.binding.http.operationselector.jsonrpc.provider.JSONRPCOperationSelectorProviderFactory;model=org.apache.tuscany.sca.binding.http.operationselector.jsonrpc.JSONRPCOperationSelector
diff --git a/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java b/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java
index fccd10f3cd..768636d478 100644
--- a/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java
+++ b/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java
@@ -39,11 +39,12 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService;
* @version $Rev$ $Date$
*/
public class HTTPBindingProviderFactory implements BindingProviderFactory<HTTPBinding> {
-
+ private ExtensionPointRegistry extensionPoints;
private MessageFactory messageFactory;
private ServletHost servletHost;
public HTTPBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
this.servletHost = servletHosts.getServletHosts().get(0);
ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
@@ -55,7 +56,7 @@ public class HTTPBindingProviderFactory implements BindingProviderFactory<HTTPBi
}
public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, RuntimeComponentService service, HTTPBinding binding) {
- return new HTTPServiceBindingProvider(component, service, binding, messageFactory, servletHost);
+ return new HTTPServiceBindingProvider(component, service, binding, extensionPoints, messageFactory, servletHost);
}
public Class<HTTPBinding> getModelType() {
diff --git a/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPRRBListenerServlet.java b/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPRRBListenerServlet.java
new file mode 100644
index 0000000000..89bea9f75a
--- /dev/null
+++ b/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPRRBListenerServlet.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.http.provider;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+
+public class HTTPRRBListenerServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 6688524143716091739L;
+
+ transient private Binding binding;
+ transient private Invoker bindingInvoker;
+ transient private MessageFactory messageFactory;
+
+ /**
+ * Constructs a new HTTPServiceListenerServlet.
+ */
+ public HTTPRRBListenerServlet(Binding binding, Invoker bindingInvoker, MessageFactory messageFactory) {
+ this.binding = binding;
+ this.bindingInvoker = bindingInvoker;
+ this.messageFactory = messageFactory;
+ }
+
+ public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ // Dispatch the service interaction to the service invoker
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setBody(new Object[]{request, response});
+ Message responseMessage = bindingInvoker.invoke(requestMessage);
+ if (responseMessage.isFault()) {
+ // Turn a fault into an exception
+ //throw new ServletException((Throwable)responseMessage.getBody());
+ Throwable e = (Throwable)responseMessage.getBody();
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
+ }
+ }
+}
diff --git a/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java b/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
index a9873b4166..bd1c1737bb 100644
--- a/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
+++ b/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
@@ -25,6 +25,7 @@ import javax.servlet.Servlet;
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.binding.http.HTTPBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.host.http.SecurityContext;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
@@ -32,12 +33,18 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.invocation.Phase;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
import org.apache.tuscany.sca.policy.authentication.AuthenticationConfigurationPolicy;
import org.apache.tuscany.sca.policy.confidentiality.ConfidentialityPolicy;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
import org.apache.tuscany.sca.provider.ServiceBindingProviderRRB;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
import org.apache.tuscany.sca.runtime.RuntimeWire;
@@ -51,21 +58,26 @@ public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB {
private static final QName AUTEHTICATION_INTENT = new QName("http://www.osoa.org/xmlns/sca/1.0","authentication");
private static final QName CONFIDENTIALITY_INTENT = new QName("http://www.osoa.org/xmlns/sca/1.0","confidentiality");
+ private RuntimeComponent component;
private RuntimeComponentService service;
private HTTPBinding binding;
private MessageFactory messageFactory;
+ private ExtensionPointRegistry extensionPoints;
private ServletHost servletHost;
private String servletMapping;
private HTTPBindingListenerServlet bindingListenerServlet;
public HTTPServiceBindingProvider(RuntimeComponent component,
- RuntimeComponentService service,
- HTTPBinding binding,
- MessageFactory messageFactory,
- ServletHost servletHost) {
+ RuntimeComponentService service,
+ HTTPBinding binding,
+ ExtensionPointRegistry extensionPoints,
+ MessageFactory messageFactory,
+ ServletHost servletHost) {
+ this.component = component;
this.service = service;
this.binding = binding;
+ this.extensionPoints = extensionPoints;
this.messageFactory = messageFactory;
this.servletHost = servletHost;
}
@@ -115,6 +127,10 @@ public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB {
Invoker serviceInvoker = invocationChain.getHeadInvoker();
servlet = new HTTPServiceListenerServlet(binding, serviceInvoker, messageFactory);
break;
+ } else if (binding.getOperationSelector() != null || binding.getRequestWireFormat() != null) {
+ Invoker bindingInvoker = wire.getBindingInvocationChain().getHeadInvoker();
+ servlet = new HTTPRRBListenerServlet(binding, bindingInvoker, messageFactory);
+ break;
}
}
if (servlet == null) {
@@ -191,9 +207,34 @@ public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB {
* @param runtimeWire
*/
public void configureBindingChain(RuntimeWire runtimeWire) {
+
InvocationChain bindingChain = runtimeWire.getBindingInvocationChain();
-
-
+
+ ProviderFactoryExtensionPoint providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+
+ // Configure the interceptors for operation selection
+ OperationSelectorProviderFactory osProviderFactory = (OperationSelectorProviderFactory) providerFactories.getProviderFactory(binding.getOperationSelector().getClass());
+ OperationSelectorProvider osProvider = null;
+ if (osProviderFactory != null) {
+ osProvider = osProviderFactory.createServiceOperationSelectorProvider(component, service, binding);
+ }
+
+ if(osProvider != null) {
+ bindingChain.addInterceptor(Phase.SERVICE_BINDING_OPERATION_SELECTOR, osProvider.createInterceptor());
+ }
+
+
+ // Configure the interceptors for wire format
+ WireFormatProviderFactory wfProviderFactory = (WireFormatProviderFactory) providerFactories.getProviderFactory(binding.getRequestWireFormat().getClass());
+ WireFormatProvider wfProvider = null;
+ if (wfProviderFactory != null) {
+ wfProvider = wfProviderFactory.createServiceWireFormatProvider(component, service, binding);
+ }
+
+ if (wfProvider != null) {
+ bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT, wfProvider.createInterceptor());
+ }
+
}
}
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
index 6cc7fff593..626e44f34f 100644
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
+++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
@@ -45,8 +45,6 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService;
import org.apache.tuscany.sca.runtime.RuntimeWire;
/**
- * Policy handler to handle PolicySet related to Logging with the QName
- * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy
*
* @version $Rev$ $Date$
*/