summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-10-26 07:46:08 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-10-26 07:46:08 +0000
commit6865c59e74f19ed6057d03583944b47abd6e036e (patch)
tree3324c11c7ca4f5ca12f15619ce30e9824e198480 /sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org
parent0d6d7922ed17cca55ec36ff2626d1080e76d6d13 (diff)
Create branch for next release
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1027394 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org')
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSBindingProviderFactory.java77
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSReferenceBindingProvider.java77
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSServiceBindingProvider.java144
3 files changed, 298 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSBindingProviderFactory.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSBindingProviderFactory.java
new file mode 100644
index 0000000000..45463fcd53
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSBindingProviderFactory.java
@@ -0,0 +1,77 @@
+/*
+ * 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.ws.jaxws.ri;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+
+/**
+ * JAXWSBindingProviderFactory
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class JAXWSBindingProviderFactory implements BindingProviderFactory<WebServiceBinding> {
+
+ private FactoryExtensionPoint modelFactories;
+ private ServletHost servletHost;
+ private DataBindingExtensionPoint dataBindings;
+ private String defaultPort = "8085";
+
+ public JAXWSBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+ List<ServletHost> hosts = servletHosts.getServletHosts();
+ if (!hosts.isEmpty()) {
+ this.servletHost = hosts.get(0);
+ }
+ modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class);
+
+ RuntimeProperties ps = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class);
+ String pp = ps.getProperties().getProperty(this.getClass().getName() + ".defaultPort");
+ if (pp != null) {
+ this.defaultPort = ps.getProperties().getProperty(this.getClass().getName() + ".defaultPort");
+ }
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ return new JAXWSReferenceBindingProvider(endpointReference, modelFactories, dataBindings);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new JAXWSServiceBindingProvider(endpoint, servletHost, modelFactories, dataBindings, defaultPort);
+ }
+
+ public Class<WebServiceBinding> getModelType() {
+ return WebServiceBinding.class;
+ }
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSReferenceBindingProvider.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSReferenceBindingProvider.java
new file mode 100644
index 0000000000..7a1b8f356a
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSReferenceBindingProvider.java
@@ -0,0 +1,77 @@
+/*
+ * 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.ws.jaxws.ri;
+
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.jaxws.JAXWSBindingInvoker;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.Node;
+
+public class JAXWSReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private javax.xml.soap.MessageFactory messageFactory;
+ private WebServiceBinding wsBinding;
+ private RuntimeEndpointReference endpointReference;
+
+ public JAXWSReferenceBindingProvider(RuntimeEndpointReference endpointReference,
+ FactoryExtensionPoint modelFactories,
+ DataBindingExtensionPoint dataBindings) {
+
+ this.endpointReference = endpointReference;
+ this.messageFactory = modelFactories.getFactory(javax.xml.soap.MessageFactory.class);
+ this.wsBinding = (WebServiceBinding) endpointReference.getBinding();
+
+ // A WSDL document should always be present in the binding
+ if (wsBinding.getGeneratedWSDLDocument() == null) {
+ throw new ServiceRuntimeException("No WSDL document for " + endpointReference.getURI());
+ }
+
+ // Set to use the DOM data binding
+ InterfaceContract contract = wsBinding.getBindingInterfaceContract();
+ if (contract.getInterface() != null) {
+ contract.getInterface().resetDataBinding(Node.class.getName());
+ }
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return wsBinding.getBindingInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ return new JAXWSBindingInvoker(operation, null, messageFactory, wsBinding, endpointReference);
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSServiceBindingProvider.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSServiceBindingProvider.java
new file mode 100644
index 0000000000..91d4bca7c0
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSServiceBindingProvider.java
@@ -0,0 +1,144 @@
+/*
+ * 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.ws.jaxws.ri;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.jaxws.JAXWSBindingProvider;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+@WebServiceProvider
+@ServiceMode(Mode.MESSAGE)
+public class JAXWSServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeEndpoint endpoint;
+ private WebServiceBinding wsBinding;
+
+ private JAXWSBindingProvider jaxwsBindingProvider;
+
+ private Endpoint wsEndpoint;
+
+ public JAXWSServiceBindingProvider(RuntimeEndpoint endpoint,
+ ServletHost servletHost,
+ FactoryExtensionPoint modelFactories,
+ DataBindingExtensionPoint dataBindings, String defaultPort) {
+
+ this.endpoint = endpoint;
+ this.wsBinding = (WebServiceBinding)endpoint.getBinding();
+
+ jaxwsBindingProvider = new JAXWSBindingProvider(endpoint,
+ servletHost,
+ modelFactories,
+ dataBindings,
+ defaultPort);
+ }
+
+ public void start() {
+ // create the JAXWS endpoint based on the provider
+ wsEndpoint = Endpoint.create(SOAPBinding.SOAP11HTTP_BINDING, jaxwsBindingProvider);
+
+ // TODO - There is something odd in the way that service name is calculated in
+ // some circumstances
+ // sometimes getServiceName() returns null
+ // sometimes getService().getQName returns a QName namespace that doesn't match the WSDL
+ // sometimes getNamespace() returns null
+ // So here we delve directly into the WSDL4J model as the Tuscany model isn't up to date
+ String targetNamespace = wsBinding.getUserSpecifiedWSDLDefinition().getDefinition().getTargetNamespace();
+
+ //set up WSDL for Provider
+ List<Source> metadata = new ArrayList<Source>();
+
+ // WSDL DOM seems to be null here so went with writing out
+ // string version of WSDL and reading it back in again
+ //Node node = wsBinding.getWSDLDefinition().getDefinition().getDocumentationElement();
+ //Source source = new DOMSource(node);
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ try {
+ WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
+ writer.writeWSDL(wsBinding.getUserSpecifiedWSDLDefinition().getDefinition(), outStream);
+ } catch (Exception ex){
+ ex.printStackTrace();
+ }
+
+ //System.out.println(outStream.toString());
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ Source source = new StreamSource(inStream);
+ source.setSystemId(targetNamespace);
+
+ metadata.add(source);
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+
+ QName portName = new QName(targetNamespace,
+ wsBinding.getPort().getName());
+ properties.put(Endpoint.WSDL_PORT, portName);
+
+ QName bindingServiceName = wsBinding.getServiceName() == null ? wsBinding.getService().getQName() : wsBinding.getServiceName();
+ QName serviceName = new QName(targetNamespace,
+ bindingServiceName.getLocalPart());
+ properties.put(Endpoint.WSDL_SERVICE, serviceName);
+
+ wsEndpoint.setMetadata(metadata);
+ wsEndpoint.setProperties(properties);
+
+ // Start up the endpoint
+
+ wsEndpoint.publish(wsBinding.getURI());
+
+
+ jaxwsBindingProvider.start();
+
+ }
+
+ public void stop() {
+ jaxwsBindingProvider.stop();
+ wsEndpoint.stop();
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return wsBinding.getBindingInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+}