You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/04/17 19:04:28 UTC
svn commit: r529675 - in /incubator/tuscany/java/sca/modules:
binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/
binding-ws-xml/
binding-ws-xml/src/main/java/org/apache/tuscany/binding/ws/xml/
binding-ws/src/main/java/org/apache/tuscany/b...
Author: rfeng
Date: Tue Apr 17 10:04:26 2007
New Revision: 529675
URL: http://svn.apache.org/viewvc?view=rev&rev=529675
Log:
Use binding interface contract to wire service/reference bindings
Modified:
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java
incubator/tuscany/java/sca/modules/binding-ws-xml/pom.xml
incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/binding/ws/xml/WebServiceBindingProcessor.java
incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/binding/ws/WebServiceBinding.java
incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/binding/ws/impl/WebServiceBindingImpl.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java?view=diff&rev=529675&r1=529674&r2=529675
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java Tue Apr 17 10:04:26 2007
@@ -40,8 +40,9 @@
import org.apache.tuscany.spi.extension.BindingBuilderExtension;
/**
- * Builds a {@link org.osoa.sca.annotations.Service} or {@link org.apache.tuscany.spi.component.ReferenceBinding} configured
- * with the Axis2 binding
+ * Builds a {@link org.osoa.sca.annotations.Service} or
+ * {@link org.apache.tuscany.spi.component.ReferenceBinding} configured with the
+ * Axis2 binding
*/
public class Axis2BindingBuilder extends BindingBuilderExtension<WebServiceBinding> {
@@ -51,8 +52,9 @@
private ServletHostExtensionPoint servletHost;
private ConfigurationContext configContext;
-//
-// private WorkContext workContext;
+
+ //
+ // private WorkContext workContext;
public Axis2BindingBuilder() {
initAxis();
@@ -68,10 +70,17 @@
}
@Override
- public ReferenceBinding build(CompositeReference compositeReference, WebServiceBinding wsBinding, DeploymentContext context) throws BuilderException {
-
- // Set to use the Axiom data binding
- compositeReference.getInterfaceContract().getInterface().setDefaultDataBinding(OMElement.class.getName());
+ public ReferenceBinding build(CompositeReference compositeReference,
+ WebServiceBinding wsBinding,
+ DeploymentContext context) throws BuilderException {
+
+ // Set to use the Axiom data binding
+ InterfaceContract contract = wsBinding.getBindingInterfaceContract();
+ if (contract == null) {
+ contract = compositeReference.getInterfaceContract();
+ wsBinding.setBindingInterfaceContract(contract);
+ }
+ contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
URI targetURI = wsBinding.getURI() != null ? URI.create(wsBinding.getURI()) : URI.create("foo");
URI name = URI.create(context.getComponentId() + "#" + compositeReference.getName());
@@ -80,22 +89,27 @@
}
@Override
- public ServiceBinding build(CompositeService compositeService, WebServiceBinding wsBinding, DeploymentContext context) throws BuilderException {
-
- InterfaceContract interfaceContract = compositeService.getInterfaceContract();
-
- // Set to use the Axiom data binding
- interfaceContract.getInterface().setDefaultDataBinding(OMElement.class.getName());
+ public ServiceBinding build(CompositeService compositeService,
+ WebServiceBinding wsBinding,
+ DeploymentContext context) throws BuilderException {
+
+ InterfaceContract contract = wsBinding.getBindingInterfaceContract();
+ if (contract == null) {
+ contract = compositeService.getInterfaceContract();
+ wsBinding.setBindingInterfaceContract(contract);
+ }
+ contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
URI uri = computeActualURI(wsBinding, BASE_URI, compositeService.getName()).normalize();
- ServiceBinding serviceBinding = new Axis2ServiceBinding(uri, interfaceContract, null, wsBinding, servletHost, configContext, null);
+ ServiceBinding serviceBinding = new Axis2ServiceBinding(uri, wsBinding, servletHost, configContext, null);
return serviceBinding;
}
protected void initAxis() {
- // TODO: consider having a system component wrapping the Axis2 ConfigContext
+ // TODO: consider having a system component wrapping the Axis2
+ // ConfigContext
try {
this.configContext = new TuscanyAxisConfigurator().getConfigurationContext();
} catch (AxisFault e) {
@@ -104,22 +118,25 @@
}
/**
- * Compute the endpoint URI based on section 2.1.1 of the WS binding spec
- * 1. The URIs in the endpoint(s) of the referenced WSDL, which may be relative
- * 2. The URI specified by the wsa:Address element of the wsa:EndpointReference, which may be relative
- * 3. The explicitly stated URI in the "uri" attribute of the binding.ws element, which may be relative,
- * 4. The implicit URI as defined by in section 1.7 in the SCA Assembly spec
- * If the <binding.ws> has no wsdlElement but does have a uri attribute then the uri takes precidence
- * over any implicitly used WSDL.
- * @param parent
+ * Compute the endpoint URI based on section 2.1.1 of the WS binding spec 1.
+ * The URIs in the endpoint(s) of the referenced WSDL, which may be relative
+ * 2. The URI specified by the wsa:Address element of the
+ * wsa:EndpointReference, which may be relative 3. The explicitly stated URI
+ * in the "uri" attribute of the binding.ws element, which may be relative,
+ * 4. The implicit URI as defined by in section 1.7 in the SCA Assembly spec
+ * If the <binding.ws> has no wsdlElement but does have a uri attribute then
+ * the uri takes precidence over any implicitly used WSDL.
+ *
+ * @param parent
*/
protected URI computeActualURI(WebServiceBinding wsBinding, String baseURI, String componentName) {
-
+
// TODO: support wsa:Address
-
- URI wsdlURI = null;
+
+ URI wsdlURI = null;
if (wsBinding.getServiceName() != null && wsBinding.getBindingName() == null) {
- // <binding.ws> explicitly points at a wsdl port, may be a relative URI
+ // <binding.ws> explicitly points at a wsdl port, may be a relative
+ // URI
wsdlURI = getEndpoint(wsBinding.getPort());
}
if (wsdlURI != null && wsdlURI.isAbsolute()) {
@@ -128,28 +145,30 @@
}
return URI.create(wsdlURI.toString());
}
-
+
// there is no wsdl port endpoint URI or that URI is relative
-
+
URI bindingURI = null;
if (wsBinding.getURI() != null) {
bindingURI = URI.create(wsBinding.getURI());
}
if (bindingURI != null && bindingURI.isAbsolute()) {
- // there is an absoulte uri specified on the binding: <binding.ws uri="xxx"
+ // there is an absoulte uri specified on the binding: <binding.ws
+ // uri="xxx"
if (wsdlURI != null) {
return URI.create(bindingURI + "/" + wsdlURI);
} else {
return bindingURI;
}
}
-
- // both the WSDL endpoint and binding uri are either unspecified or relative so
+
+ // both the WSDL endpoint and binding uri are either unspecified or
+ // relative so
// the endpoint is based on the component uri and service name
-
+
URI componentURI = URI.create(componentName);
-
+
if (componentURI == null) { // null for references
wsdlURI = getEndpoint(wsBinding.getPort());
if (bindingURI != null) {
@@ -159,13 +178,16 @@
}
}
- // TODO: TUSCANY-xxx, how to tell if component has multiple services using <binding.ws>?
- // boolean singleService = (parent != null) && (((Component)parent.getChild(componentURI.toString())).getInboundWires().size() == 1);
- // if (bindingURI == null && !singleService) {
-
-// if (bindingURI == null) {
-// bindingURI = URI.create(bindingName);
-// }
+ // TODO: TUSCANY-xxx, how to tell if component has multiple services
+ // using <binding.ws>?
+ // boolean singleService = (parent != null) &&
+ // (((Component)parent.getChild(componentURI.toString())).getInboundWires().size()
+ // == 1);
+ // if (bindingURI == null && !singleService) {
+
+ // if (bindingURI == null) {
+ // bindingURI = URI.create(bindingName);
+ // }
if (componentURI.isAbsolute()) {
if (bindingURI == null && wsdlURI == null) {
@@ -178,7 +200,7 @@
return URI.create(componentURI + "/" + bindingURI + "/" + wsdlURI);
}
}
-
+
String actualURI = "";
if (bindingURI == null) {
@@ -192,9 +214,9 @@
}
if (actualURI.endsWith("/")) {
- actualURI = actualURI.substring(0, actualURI.length() -1);
+ actualURI = actualURI.substring(0, actualURI.length() - 1);
}
-
+
return URI.create(actualURI);
}
@@ -206,7 +228,7 @@
final List wsdlPortExtensions = wsdlPort.getExtensibilityElements();
for (final Object extension : wsdlPortExtensions) {
if (extension instanceof SOAPAddress) {
- return URI.create(((SOAPAddress) extension).getLocationURI());
+ return URI.create(((SOAPAddress)extension).getLocationURI());
}
}
}
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java?view=diff&rev=529675&r1=529674&r2=529675
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java Tue Apr 17 10:04:26 2007
@@ -59,6 +59,7 @@
super(name, targetUri);
this.wsBinding = wsBinding;
this.serviceClient = createServiceClient();
+ this.bindingServiceContract = wsBinding.getBindingInterfaceContract();
}
public QName getBindingType() {
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java?view=diff&rev=529675&r1=529674&r2=529675
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java Tue Apr 17 10:04:26 2007
@@ -69,8 +69,6 @@
* An implementation of a {@link ServiceBindingExtension} configured with the Axis2 binding
*/
public class Axis2ServiceBinding extends ServiceBindingExtension {
-
- private InterfaceContract serviceContract;
private ConfigurationContext configContext;
private WebServiceBinding wsBinding;
private Map<Object, InvocationContext> invCtxMap = new HashMap<Object, InvocationContext>();
@@ -82,8 +80,6 @@
private static final QName BINDING_WS = new QName(SCA_NS, "binding.ws");
public Axis2ServiceBinding(URI uri,
- InterfaceContract serviceContract,
- InterfaceContract serviceBindingContract,
WebServiceBinding wsBinding,
ServletHostExtensionPoint servletHost,
ConfigurationContext configContext,
@@ -91,8 +87,7 @@
super(uri);
- this.serviceContract = serviceContract;
- this.bindingServiceContract = serviceBindingContract;
+ this.bindingServiceContract = wsBinding.getBindingInterfaceContract();
this.wsBinding = wsBinding;
this.servletHost = servletHost;
this.configContext = configContext;
@@ -167,7 +162,7 @@
}
MessageReceiver msgrec = null;
- if (serviceContract.getCallbackInterface() != null) {
+ if (bindingServiceContract.getCallbackInterface() != null) {
msgrec = new Axis2ServiceInOutAsyncMessageReceiver(this, op);
} else if (op.isNonBlocking()) {
msgrec = new Axis2ServiceInMessageReceiver(this, op);
@@ -183,7 +178,7 @@
protected Operation getOperation(AxisOperation axisOp) {
String operationName = axisOp.getName().getLocalPart();
- for (Operation op : serviceContract.getInterface().getOperations()) {
+ for (Operation op : bindingServiceContract.getInterface().getOperations()) {
if (op.getName().equalsIgnoreCase(operationName)) {
return op;
}
@@ -370,7 +365,7 @@
}
boolean isConversational() {
- return serviceContract.getInterface().isConversational();
+ return bindingServiceContract.getInterface().isConversational();
}
}
Modified: incubator/tuscany/java/sca/modules/binding-ws-xml/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-xml/pom.xml?view=diff&rev=529675&r1=529674&r2=529675
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-xml/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-xml/pom.xml Tue Apr 17 10:04:26 2007
@@ -51,5 +51,11 @@
<artifactId>tuscany-interface-wsdl</artifactId>
<version>1.0-incubating-SNAPSHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl-xml</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
Modified: incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/binding/ws/xml/WebServiceBindingProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/binding/ws/xml/WebServiceBindingProcessor.java?view=diff&rev=529675&r1=529674&r2=529675
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/binding/ws/xml/WebServiceBindingProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/binding/ws/xml/WebServiceBindingProcessor.java Tue Apr 17 10:04:26 2007
@@ -21,8 +21,11 @@
import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import java.util.Map;
+
import javax.wsdl.Definition;
import javax.wsdl.Port;
+import javax.wsdl.PortType;
import javax.wsdl.Service;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
@@ -42,92 +45,111 @@
import org.apache.tuscany.contribution.service.ContributionResolveException;
import org.apache.tuscany.contribution.service.ContributionWireException;
import org.apache.tuscany.contribution.service.ContributionWriteException;
+import org.apache.tuscany.interfacedef.InvalidInterfaceException;
import org.apache.tuscany.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.interfacedef.wsdl.WSDLInterfaceContract;
import org.apache.tuscany.interfacedef.wsdl.impl.DefaultWSDLFactory;
+import org.apache.tuscany.interfacedef.wsdl.introspect.DefaultWSDLInterfaceIntrospector;
+import org.apache.tuscany.interfacedef.wsdl.introspect.WSDLInterfaceIntrospector;
import org.apache.tuscany.policy.PolicyFactory;
import org.apache.tuscany.policy.impl.DefaultPolicyFactory;
-public class WebServiceBindingProcessor extends BaseArtifactProcessor implements StAXArtifactProcessorExtension<WebServiceBinding>, WebServiceConstants {
+public class WebServiceBindingProcessor extends BaseArtifactProcessor implements
+ StAXArtifactProcessorExtension<WebServiceBinding>, WebServiceConstants {
+ private WSDLFactory wsdlFactory;
+ private WSDLInterfaceIntrospector introspector;
private WebServiceBindingFactory wsFactory;
public WebServiceBindingProcessor(AssemblyFactory assemblyFactory,
PolicyFactory policyFactory,
- WebServiceBindingFactory wsFactory) {
+ WebServiceBindingFactory wsFactory,
+ WSDLFactory wsdlFactory,
+ WSDLInterfaceIntrospector introspector) {
super(assemblyFactory, policyFactory, null);
this.wsFactory = wsFactory;
+ this.introspector = introspector;
+ this.wsdlFactory = wsdlFactory;
}
-
+
public WebServiceBindingProcessor() {
- this(new DefaultAssemblyFactory(), new DefaultPolicyFactory(), new DefaultWebServiceBindingFactory());
+ this(new DefaultAssemblyFactory(), new DefaultPolicyFactory(), new DefaultWebServiceBindingFactory(),
+ new DefaultWSDLFactory(), new DefaultWSDLInterfaceIntrospector());
+
}
public WebServiceBinding read(XMLStreamReader reader) throws ContributionReadException {
try {
-
+
// Read a <binding.ws>
WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
wsBinding.setUnresolved(true);
-
+
// Read policies
readPolicies(wsBinding, reader);
// Read URI
wsBinding.setURI(reader.getAttributeValue(null, Constants.URI));
-
+
// Read a qname in the form:
// namespace#wsdl.???(name)
String wsdlElement = reader.getAttributeValue(null, WSDL_ELEMENT);
if (wsdlElement != null) {
int index = wsdlElement.indexOf('#');
if (index == -1) {
- throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
+ throw new ContributionReadException(
+ "Invalid WebService binding wsdlElement attribute: " + wsdlElement);
}
String namespace = wsdlElement.substring(0, index);
wsBinding.setNamespace(namespace);
String name = wsdlElement.substring(index + 1);
if (name.startsWith("wsdl.service")) {
-
+
// Read a wsdl.service
name = name.substring("wsdl.service(".length(), name.length() - 1);
wsBinding.setServiceName(new QName(namespace, name));
-
+
} else if (name.startsWith("wsdl.port")) {
-
+
// Read a wsdl.port
name = name.substring("wsdl.port(".length(), name.length() - 1);
int s = name.indexOf('/');
if (s == -1) {
- throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
+ throw new ContributionReadException(
+ "Invalid WebService binding wsdlElement attribute: " + wsdlElement);
}
wsBinding.setServiceName(new QName(namespace, name.substring(0, s)));
- wsBinding.setPortName(name.substring(s+1));
-
+ wsBinding.setPortName(name.substring(s + 1));
+
} else if (name.startsWith("wsdl.endpoint")) {
-
+
// Read a wsdl.endpoint
name = name.substring("wsdl.endpoint(".length(), name.length() - 1);
int s = name.indexOf('/');
if (s == -1) {
- throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
+ throw new ContributionReadException(
+ "Invalid WebService binding wsdlElement attribute: " + wsdlElement);
}
wsBinding.setServiceName(new QName(namespace, name.substring(0, s)));
- wsBinding.setEndpointName(name.substring(s+1));
-
+ wsBinding.setEndpointName(name.substring(s + 1));
+
} else if (name.startsWith("wsdl.binding")) {
-
+
// Read a wsdl.service
name = name.substring("wsdl.binding(".length(), name.length() - 1);
wsBinding.setBindingName(new QName(namespace, name));
-
+
} else {
- throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
+ throw new ContributionReadException(
+ "Invalid WebService binding wsdlElement attribute: " + wsdlElement);
}
}
-
+
// Read wsdlLocation
wsBinding.setLocation(reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION));
-
+
// Skip to end element
while (reader.hasNext()) {
if (reader.next() == END_ELEMENT && BINDING_WS_QNAME.equals(reader.getName())) {
@@ -135,17 +157,17 @@
}
}
return wsBinding;
-
+
} catch (XMLStreamException e) {
throw new ContributionReadException(e);
}
}
-
+
public void write(WebServiceBinding wsBinding, XMLStreamWriter writer) throws ContributionWriteException {
try {
// Write a <binding.ws>
writer.writeStartElement(Constants.SCA10_NS, BINDING_WS);
-
+
// Write binding URI
if (wsBinding.getURI() != null) {
writer.writeAttribute(Constants.URI, wsBinding.getURI());
@@ -155,46 +177,52 @@
if (wsBinding.getPortName() != null) {
// Write namespace#wsdl.port(service/port)
- String wsdlElement = wsBinding.getServiceName().getNamespaceURI() +
- "#wsdl.port(" + wsBinding.getServiceName().getLocalPart() + "/" +
- wsBinding.getPortName() + ")";
+ String wsdlElement = wsBinding.getServiceName().getNamespaceURI() + "#wsdl.port("
+ + wsBinding.getServiceName().getLocalPart()
+ + "/"
+ + wsBinding.getPortName()
+ + ")";
writer.writeAttribute(WSDL_ELEMENT, wsdlElement);
-
+
} else if (wsBinding.getEndpointName() != null) {
// Write namespace#wsdl.endpoint(service/endpoint)
- String wsdlElement = wsBinding.getServiceName().getNamespaceURI() +
- "#wsdl.endpoint(" + wsBinding.getServiceName().getLocalPart() + "/" +
- wsBinding.getEndpointName() + ")";
+ String wsdlElement = wsBinding.getServiceName().getNamespaceURI() + "#wsdl.endpoint("
+ + wsBinding.getServiceName().getLocalPart()
+ + "/"
+ + wsBinding.getEndpointName()
+ + ")";
writer.writeAttribute(WSDL_ELEMENT, wsdlElement);
} else if (wsBinding.getBindingName() != null) {
-
+
// Write namespace#wsdl.binding(binding)
- String wsdlElement = wsBinding.getBindingName().getNamespaceURI() +
- "#wsdl.binding(" + wsBinding.getBindingName().getLocalPart() + ")";
+ String wsdlElement = wsBinding.getBindingName().getNamespaceURI() + "#wsdl.binding("
+ + wsBinding.getBindingName().getLocalPart()
+ + ")";
writer.writeAttribute(WSDL_ELEMENT, wsdlElement);
} else if (wsBinding.getServiceName() != null) {
-
+
// Write namespace#wsdl.service(service)
- String wsdlElement = wsBinding.getServiceName().getNamespaceURI() +
- "#wsdl.service(" + wsBinding.getServiceName().getLocalPart() + ")";
+ String wsdlElement = wsBinding.getServiceName().getNamespaceURI() + "#wsdl.service("
+ + wsBinding.getServiceName().getLocalPart()
+ + ")";
writer.writeAttribute(WSDL_ELEMENT, wsdlElement);
}
-
+
// Write location
if (wsBinding.getLocation() != null) {
writer.writeAttribute(WSDLI_NS, WSDL_LOCATION, wsBinding.getLocation());
}
-
+
writer.writeEndElement();
-
+
} catch (XMLStreamException e) {
throw new ContributionWriteException(e);
}
}
-
+
public void resolve(WebServiceBinding model, ArtifactResolver resolver) throws ContributionResolveException {
WSDLDefinition wsdlDefinition = new DefaultWSDLFactory().createWSDLDefinition();
wsdlDefinition.setUnresolved(true);
@@ -215,17 +243,51 @@
model.setBinding(port.getBinding());
}
}
+
+ PortType portType = getPortType(model);
+ if (portType != null) {
+ WSDLInterfaceContract interfaceContract = wsdlFactory.createWSDLInterfaceContract();
+ WSDLInterface wsdlInterface;
+ try {
+ wsdlInterface = introspector.introspect(portType,
+ wsdlDefinition.getInlinedSchemas(),
+ resolver);
+ } catch (InvalidInterfaceException e) {
+ throw new ContributionResolveException(e);
+ }
+ interfaceContract.setInterface(wsdlInterface);
+ model.setBindingInterfaceContract(interfaceContract);
+ }
}
}
-
+
+ private PortType getPortType(WebServiceBinding model) {
+ PortType portType = null;
+ if (model.getService() != null) {
+ // FIXME: How to find the compatible port?
+ Map ports = model.getService().getPorts();
+ if (!ports.isEmpty()) {
+ Port port = (Port)ports.values().iterator().next();
+ portType = port.getBinding().getPortType();
+ }
+ } else if (model.getPort() != null) {
+ portType = model.getPort().getBinding().getPortType();
+ } else if (model.getEndpoint() != null) {
+ portType = model.getPort().getBinding().getPortType();
+ } else if (model.getBinding() != null) {
+ portType = model.getBinding().getPortType();
+ }
+ return portType;
+ }
+
public void wire(WebServiceBinding model) throws ContributionWireException {
// TODO Auto-generated method stub
}
-
+
public QName getArtifactType() {
return WebServiceConstants.BINDING_WS_QNAME;
}
-
+
public Class<WebServiceBinding> getModelType() {
return WebServiceBinding.class;
}
Modified: incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/binding/ws/WebServiceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/binding/ws/WebServiceBinding.java?view=diff&rev=529675&r1=529674&r2=529675
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/binding/ws/WebServiceBinding.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/binding/ws/WebServiceBinding.java Tue Apr 17 10:04:26 2007
@@ -23,6 +23,7 @@
import javax.xml.namespace.QName;
import org.apache.tuscany.assembly.Binding;
+import org.apache.tuscany.interfacedef.InterfaceContract;
import org.apache.tuscany.interfacedef.wsdl.WSDLDefinition;
@@ -172,4 +173,7 @@
* @param namspace the WSDL namspace
*/
void setNamespace(String namespace);
+
+ InterfaceContract getBindingInterfaceContract();
+ void setBindingInterfaceContract(InterfaceContract bindingInterfaceContract);
}
Modified: incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/binding/ws/impl/WebServiceBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/binding/ws/impl/WebServiceBindingImpl.java?view=diff&rev=529675&r1=529674&r2=529675
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/binding/ws/impl/WebServiceBindingImpl.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/binding/ws/impl/WebServiceBindingImpl.java Tue Apr 17 10:04:26 2007
@@ -26,6 +26,7 @@
import org.apache.tuscany.assembly.impl.BindingImpl;
import org.apache.tuscany.binding.ws.WebServiceBinding;
+import org.apache.tuscany.interfacedef.InterfaceContract;
import org.apache.tuscany.interfacedef.wsdl.WSDLDefinition;
/**
@@ -47,6 +48,8 @@
private WSDLDefinition wsdlDefinition;
private String wsdlNamespace;
+ private InterfaceContract bindingInterfaceContract;
+
public String getLocation() {
return location;
}
@@ -170,6 +173,14 @@
public void setNamespace(String namespace) {
this.wsdlNamespace = namespace;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return bindingInterfaceContract;
+ }
+
+ public void setBindingInterfaceContract(InterfaceContract bindingInterfaceContract) {
+ this.bindingInterfaceContract = bindingInterfaceContract;
}
}
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java?view=diff&rev=529675&r1=529674&r2=529675
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java Tue Apr 17 10:04:26 2007
@@ -91,7 +91,11 @@
private WorkScheduler workScheduler;
private WorkContext workContext;
- public DeployerImpl(XMLInputFactory xmlFactory, Builder builder, ComponentManager componentManager, WorkScheduler workScheduler, WorkContext workContext) {
+ public DeployerImpl(XMLInputFactory xmlFactory,
+ Builder builder,
+ ComponentManager componentManager,
+ WorkScheduler workScheduler,
+ WorkContext workContext) {
this.xmlFactory = xmlFactory;
this.builder = builder;
this.componentManager = componentManager;
@@ -205,12 +209,11 @@
}
}
}
-
- public void configureProperties(Component source,
- org.apache.tuscany.assembly.Component definition) throws BuilderException {
+
+ public void configureProperties(Component source, org.apache.tuscany.assembly.Component definition)
+ throws BuilderException {
if (source == null) {
- throw new ComponentNotFoundException("Source not found", URI.create(definition
- .getName()));
+ throw new ComponentNotFoundException("Source not found", URI.create(definition.getName()));
}
for (ComponentProperty property : definition.getProperties()) {
@@ -220,7 +223,6 @@
}
}
-
public void connect(Component source, org.apache.tuscany.assembly.Component definition) throws WiringException {
if (definition.getImplementation() instanceof Composite) {
@@ -240,7 +242,10 @@
// FIXME: Assume we only have one binding
ReferenceBinding binding = target.getReferenceBindings().get(0);
URI targetUri = binding.getUri();
- InterfaceContract contract = compositeReference.getInterfaceContract();
+ InterfaceContract contract = binding.getBindingInterfaceContract();
+ if (contract == null) {
+ contract = compositeReference.getInterfaceContract();
+ }
QName type = binding.getBindingType();
URI sourceUri = URI.create(source.getUri() + "#" + refName);
Wire wire;
@@ -323,14 +328,18 @@
}
URI sourceURI = service.getUri();
URI targetURI = URI.create(target.getUri() + "#" + definition.getPromotedService().getName());
- InterfaceContract sourceContract = definition.getInterfaceContract();
InterfaceContract targetContract = definition.getPromotedService().getService().getInterfaceContract();
- if (sourceContract == null) {
- sourceContract = targetContract;
- }
// TODO if no binding, do local
for (ServiceBinding binding : service.getServiceBindings()) {
+ InterfaceContract sourceContract = binding.getBindingInterfaceContract();
+ if (sourceContract == null) {
+ sourceContract = definition.getInterfaceContract();
+ }
+ if (sourceContract == null) {
+ sourceContract = targetContract;
+ }
+
Wire wire = createWire(sourceURI, targetURI, sourceContract, targetContract, binding.getBindingType());
binding.setWire(wire);
if (postProcessorRegistry != null) {
@@ -356,10 +365,10 @@
* @throws IncompatibleInterfaceContractException
*/
private Wire createWire(URI sourceURI,
- URI targetUri,
- InterfaceContract sourceContract,
- InterfaceContract targetContract,
- QName bindingType) throws IncompatibleInterfaceContractException {
+ URI targetUri,
+ InterfaceContract sourceContract,
+ InterfaceContract targetContract,
+ QName bindingType) throws IncompatibleInterfaceContractException {
Wire wire = new WireImpl(bindingType);
wire.setSourceContract(sourceContract);
wire.setTargetContract(targetContract);
@@ -370,10 +379,11 @@
for (Operation operation : sourceContract.getInterface().getOperations()) {
Operation targetOperation = mapper.map(targetContract.getInterface(), operation);
InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
- /* lresende */
- if (operation.isNonBlocking()) {
- chain.addInterceptor(new NonBlockingInterceptor(workScheduler, workContext)); }
- /* lresende */
+ /* lresende */
+ if (operation.isNonBlocking()) {
+ chain.addInterceptor(new NonBlockingInterceptor(workScheduler, workContext));
+ }
+ /* lresende */
chain.addInterceptor(new InvokerInterceptor());
wire.addInvocationChain(chain);
@@ -382,10 +392,11 @@
for (Operation operation : sourceContract.getCallbackInterface().getOperations()) {
Operation targetOperation = mapper.map(targetContract.getCallbackInterface(), operation);
InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
- /* lresende */
- if (operation.isNonBlocking()) {
- chain.addInterceptor(new NonBlockingInterceptor(workScheduler, workContext)); }
- /* lresende */
+ /* lresende */
+ if (operation.isNonBlocking()) {
+ chain.addInterceptor(new NonBlockingInterceptor(workScheduler, workContext));
+ }
+ /* lresende */
chain.addInterceptor(new InvokerInterceptor());
wire.addCallbackInvocationChain(chain);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org