summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java6
-rw-r--r--sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java33
-rw-r--r--sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java6
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java4
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java2
-rw-r--r--sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java12
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java44
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java23
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java27
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/pom.xml7
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java/pom.xml6
-rw-r--r--sca-java-2.x/trunk/modules/interface-java-jaxws/META-INF/MANIFEST.MF1
-rw-r--r--sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java34
-rw-r--r--sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSUtils.java310
-rw-r--r--sca-java-2.x/trunk/modules/interface-java/META-INF/MANIFEST.MF2
-rw-r--r--sca-java-2.x/trunk/modules/interface-java/pom.xml6
-rw-r--r--sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java77
-rw-r--r--sca-java-2.x/trunk/modules/interface-wsdl/pom.xml4
-rw-r--r--sca-java-2.x/trunk/modules/node-impl/pom.xml7
19 files changed, 562 insertions, 49 deletions
diff --git a/sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java b/sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java
index 5017c7d8ef..9cb6374b7c 100644
--- a/sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java
+++ b/sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java
@@ -33,10 +33,13 @@ import org.junit.Test;
* Current required jars are:
*
* activation-1.1.jar
+ * asm-3.1.jar
* geronimo-stax-api_1.0_spec-1.0.1.jar
* jaxb-api-2.1.jar
* jaxb-impl-2.1.12.jar
+ * jaxws-api-2.1.jar
* jsr181-api-1.0-MR1.jar
+ * jsr250-api-1.0.jar
* junit-4.8.1.jar
* tuscany-assembly-2.0-SNAPSHOT.jar
* tuscany-assembly-xml-2.0-SNAPSHOT.jar
@@ -56,6 +59,7 @@ import org.junit.Test;
* tuscany-extensibility-2.0-SNAPSHOT.jar
* tuscany-implementation-java-2.0-SNAPSHOT.jar
* tuscany-interface-java-2.0-SNAPSHOT.jar
+ * tuscany-interface-java-jaxws-2.0-SNAPSHOT.jar
* tuscany-interface-wsdl-2.0-SNAPSHOT.jar
* tuscany-monitor-2.0-SNAPSHOT.jar
* tuscany-sca-api-2.0-SNAPSHOT.jar
@@ -75,6 +79,6 @@ public class ValidateDependenciesTestCase {
Assert.assertTrue(dependenciesDir.exists());
File[] dependencyFiles = dependenciesDir.listFiles();
- Assert.assertEquals(31, dependencyFiles.length);
+ Assert.assertEquals(35, dependencyFiles.length);
}
}
diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java
index 757beeae7d..0668761e48 100644
--- a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java
+++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java
@@ -24,6 +24,7 @@ import java.util.Map;
import javax.xml.namespace.QName;
+import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
@@ -159,5 +160,35 @@ public class TestInterface implements JavaInterface {
// TODO Auto-generated method stub
}
-
+
+ public String getJAXWSJavaInterfaceName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setJAXWSJavaInterfaceName(String javaInterfaceName) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public String getJAXWSWSDLLocation() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setJAXWSWSDLLocation(String wsdlLocation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Contribution getContributionContainingClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setContributionContainingClass(
+ Contribution contributionContainingClass) {
+ // TODO Auto-generated method stub
+
+ }
}
diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java
index 616282abfb..2896114775 100644
--- a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java
+++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java
@@ -301,5 +301,11 @@ public class TestRuntimeWire implements RuntimeEndpoint {
// TODO Auto-generated method stub
}
+
+ public InterfaceContract getGeneratedWSDLContract(
+ InterfaceContract interfaceContract) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java
index d147d85ef3..f905c10bf7 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java
+++ b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java
@@ -58,7 +58,7 @@ public class BindingWSDLGeneratorTestCase extends TestCase {
JavaInterface iface = factory.createJavaInterface(HelloWorld.class);
DefaultDataBindingExtensionPoint dataBindings = new DefaultDataBindingExtensionPoint(registry);
JAXWSFaultExceptionMapper faultExceptionMapper = new JAXWSFaultExceptionMapper(dataBindings, null);
- new JAXWSJavaInterfaceProcessor(dataBindings, faultExceptionMapper, null).visitInterface(iface);
+ new JAXWSJavaInterfaceProcessor(registry).visitInterface(iface);
new DataBindingJavaInterfaceProcessor(registry).visitInterface(iface);
javaIC.setInterface(iface);
WSDLInterfaceContract wsdlIC = BindingWSDLGenerator.createWSDLInterfaceContract(javaIC, false, new XSDModelResolver(null, null), dataBindings, wsdlFactory, xsdFactory, documentBuilderFactory, null);
@@ -71,7 +71,7 @@ public class BindingWSDLGeneratorTestCase extends TestCase {
JavaInterfaceContract javaIC2 = factory.createJavaInterfaceContract();
JavaInterface iface2 = factory.createJavaInterface(TestJavaInterface.class);
- new JAXWSJavaInterfaceProcessor(dataBindings, faultExceptionMapper, null).visitInterface(iface2);
+ new JAXWSJavaInterfaceProcessor(registry).visitInterface(iface2);
new DataBindingJavaInterfaceProcessor(registry).visitInterface(iface2);
javaIC2.setInterface(iface2);
WSDLInterfaceContract wsdlIC2 = BindingWSDLGenerator.createWSDLInterfaceContract(javaIC2, false, new XSDModelResolver(null, null), dataBindings, wsdlFactory, xsdFactory, documentBuilderFactory, null);
diff --git a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java
index 33d5bea838..c80a929a90 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java
+++ b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java
@@ -55,7 +55,7 @@ public class Interface2WSDLGeneratorTestCase {
JavaInterface iface = iFactory.createJavaInterface(TestJavaInterface.class);
DefaultDataBindingExtensionPoint dataBindings = new DefaultDataBindingExtensionPoint(new DefaultExtensionPointRegistry());
JAXWSFaultExceptionMapper faultExceptionMapper = new JAXWSFaultExceptionMapper(dataBindings, null);
- new JAXWSJavaInterfaceProcessor(dataBindings, faultExceptionMapper, null).visitInterface(iface);
+ new JAXWSJavaInterfaceProcessor(registry).visitInterface(iface);
new DataBindingJavaInterfaceProcessor(registry).visitInterface(iface);
DefaultFactoryExtensionPoint modelFactories = new DefaultFactoryExtensionPoint(registry);
WSDLFactory wFactory = new DefaultWSDLFactory(registry);
diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java
index 081fdac828..1ba394dde9 100644
--- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java
+++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java
@@ -49,6 +49,10 @@ public class ClassLoaderModelResolver extends URLClassLoader implements ModelRes
private WeakReference<Contribution> contribution;
private ProcessorContext context;
private Map<String, ModelResolver> importResolvers = new HashMap<String, ModelResolver>();
+
+ // a space to pass back the contribution that was used to resolve
+ // a class via an import
+ private Contribution contributionContainingClass;
private static ClassLoader parentClassLoader(Contribution contribution) {
if (contribution.getClassLoader() != null) {
@@ -107,10 +111,15 @@ public class ClassLoaderModelResolver extends URLClassLoader implements ModelRes
try {
this.context = context;
+ contributionContainingClass = contribution.get();
+
// Load the class and return a class reference for it
String className = ((ClassReference)unresolved).getClassName();
Class<?> clazz = Class.forName(className, false, this);
- return modelClass.cast(new ClassReference(clazz));
+ ClassReference classReference = new ClassReference(clazz);
+ classReference.setContributionContainingClass(contributionContainingClass);
+ contributionContainingClass = null;
+ return modelClass.cast(classReference);
} catch (ClassNotFoundException e) {
return unresolved;
@@ -160,6 +169,7 @@ public class ClassLoaderModelResolver extends URLClassLoader implements ModelRes
if (importResolver != null) {
ClassReference classReference = importResolver.resolveModel(ClassReference.class, new ClassReference(name), context);
if (!classReference.isUnresolved()) {
+ contributionContainingClass = classReference.getContributionContainingClass();
return classReference.getJavaClass();
}
}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
index e294f9c270..44dbeda11f 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
@@ -494,27 +494,39 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
InterfaceContract serviceContract = getComponentServiceInterfaceContract();
InterfaceContract bindingContract = getBindingInterfaceContract();
-
+
if ((serviceContract != null) &&
(bindingContract != null)){
boolean bindingHasCallback = bindingContract.getCallbackInterface() != null;
try {
- if ((serviceContract.getClass() != bindingContract.getClass()) &&
- (serviceContract instanceof JavaInterfaceContract)) {
- interfaceContractMapper.checkCompatibility(getGeneratedWSDLContract(serviceContract),
- bindingContract,
- Compatibility.SUBSET,
- !bindingHasCallback, // ignore callbacks if binding doesn't have one
- false);
- } else {
- interfaceContractMapper.checkCompatibility(serviceContract,
- bindingContract,
- Compatibility.SUBSET,
- !bindingHasCallback, // ignore callbacks if binding doesn't have one
- false);
- }
+/*
+ interfaceContractMapper.checkCompatibility(getGeneratedWSDLContract(serviceContract),
+ getGeneratedWSDLContract(bindingContract),
+ Compatibility.SUBSET,
+ !bindingHasCallback, // ignore callbacks if binding doesn't have one
+ false);
+*/
+
+ // Use the normalized contract if the interface types are different or if
+ // a normalized contract has been previously generate, for example, by virtue
+ // of finding a JAXWS annotation on a Java class that references a WSDL file
+ if (serviceContract.getClass() != bindingContract.getClass() ||
+ serviceContract.getNormalizedWSDLContract() != null ||
+ bindingContract.getNormalizedWSDLContract() != null) {
+ interfaceContractMapper.checkCompatibility(getGeneratedWSDLContract(serviceContract),
+ getGeneratedWSDLContract(bindingContract),
+ Compatibility.SUBSET,
+ !bindingHasCallback, // ignore callbacks if binding doesn't have one
+ false);
+ } else {
+ interfaceContractMapper.checkCompatibility(serviceContract,
+ bindingContract,
+ Compatibility.SUBSET,
+ !bindingHasCallback, // ignore callbacks if binding doesn't have one
+ false);
+ }
} catch (Exception ex){
throw new ServiceRuntimeException("Component " +
this.getComponent().getName() +
@@ -817,7 +829,7 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
if (contractBuilder == null){
throw new ServiceRuntimeException("Contract builder not found while calculating WSDL contract for " + this.toString());
}
- contractBuilder.build(getComponentServiceInterfaceContract(), null);
+ contractBuilder.build(interfaceContract, null);
}
}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
index 3873185e6b..5f5bbb19ce 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
@@ -325,15 +325,25 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
if ((referenceContract != null) &&
(bindingContract != null)){
-
+
boolean bindingHasCallback = bindingContract.getCallbackInterface() != null;
try {
-
- if ((referenceContract.getClass() != bindingContract.getClass()) &&
- (referenceContract instanceof JavaInterfaceContract)) {
+/*
+ interfaceContractMapper.checkCompatibility(getGeneratedWSDLContract(referenceContract),
+ getGeneratedWSDLContract(bindingContract),
+ Compatibility.SUBSET,
+ !bindingHasCallback, // ignore callbacks if binding doesn't have one
+ false);
+*/
+ // Use the normalized contract if the interface types are different or if
+ // a normalized contract has been previously generate, for example, by virtue
+ // of finding a JAXWS annotation on a Java class that references a WSDL file
+ if (referenceContract.getClass() != bindingContract.getClass() ||
+ referenceContract.getNormalizedWSDLContract() != null ||
+ bindingContract.getNormalizedWSDLContract() != null) {
interfaceContractMapper.checkCompatibility(getGeneratedWSDLContract(referenceContract),
- bindingContract,
+ getGeneratedWSDLContract(bindingContract),
Compatibility.SUBSET,
!bindingHasCallback, // ignore callbacks if binding doesn't have one
false);
@@ -344,7 +354,6 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
!bindingHasCallback, // ignore callbacks if binding doesn't have one
false);
}
-
} catch (Exception ex){
throw new ServiceRuntimeException("Component " +
this.getComponent().getName() +
@@ -608,7 +617,7 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
if (contractBuilder == null){
throw new ServiceRuntimeException("Contract builder not found while calculating WSDL contract for " + this.toString());
}
- contractBuilder.build(getComponentReferenceInterfaceContract(), null);
+ contractBuilder.build(interfaceContract, null);
}
}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
index dfeebe2ec6..96d44b3bc2 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
@@ -44,7 +44,10 @@ import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointReferenceImpl;
import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
import org.apache.tuscany.sca.interfacedef.util.Audit;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
@@ -776,7 +779,10 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
private boolean haveMatchingInterfaceContracts(EndpointReference endpointReference, Endpoint endpoint, Audit matchAudit){
matchAudit.append("Match interface of " + endpointReference.toString() + " to " + endpoint.toString() + " ");
- if (endpointReference.getReference().getInterfaceContract() == null){
+ InterfaceContract endpointReferenceContract = endpointReference.getReference().getInterfaceContract();
+ InterfaceContract endpointContract = endpoint.getComponentServiceInterfaceContract();
+
+ if (endpointReferenceContract == null){
matchAudit.append("Match because there is no interface contract on the reference ");
matchAudit.appendSeperator();
return true;
@@ -784,7 +790,8 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
// TODO - is there a better test for this. Would have to cast to the
// correct iface type to get to the resolved flag
- if (endpoint.getComponentServiceInterfaceContract().getInterface().getOperations().size() == 0){
+ // We need to rely on normailzed interfaces in this case!!
+ if (endpointContract.getInterface().getOperations().size() == 0){
// the interface contract is likely remote but unresolved
// we discussed this on the ML and decided that we could
// live with this for the case where there is no central matching of references
@@ -793,13 +800,23 @@ public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
matchAudit.appendSeperator();
return true;
}
+
+ // If the contracts are not of the same type or normalized interfaces are available
+ // use them
+ if (endpointReferenceContract.getClass() != endpointContract.getClass() ||
+ endpointReferenceContract.getNormalizedWSDLContract() != null ||
+ endpointContract.getNormalizedWSDLContract() != null) {
+ endpointReferenceContract = ((RuntimeEndpointReference)endpointReference).getGeneratedWSDLContract(endpointReferenceContract);
+ endpointContract = ((RuntimeEndpoint)endpoint).getGeneratedWSDLContract(endpointContract);
+ }
boolean match = false;
- match = interfaceContractMapper.isCompatibleSubset(endpointReference.getReference().getInterfaceContract(),
- endpoint.getComponentServiceInterfaceContract(), matchAudit);
+ match = interfaceContractMapper.isCompatibleSubset(endpointReferenceContract,
+ endpointContract,
+ matchAudit);
if (!match){
- matchAudit.append("Match failed because the linterface contract mapper failed ");
+ matchAudit.append("Match failed because the interface contract mapper failed ");
} else {
matchAudit.append("Match because the interface contract mapper succeeded ");
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/pom.xml b/sca-java-2.x/trunk/modules/domain-node/pom.xml
index 9cda8ebb9c..b4980b2105 100644
--- a/sca-java-2.x/trunk/modules/domain-node/pom.xml
+++ b/sca-java-2.x/trunk/modules/domain-node/pom.xml
@@ -62,6 +62,13 @@
<version>2.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
diff --git a/sca-java-2.x/trunk/modules/implementation-java/pom.xml b/sca-java-2.x/trunk/modules/implementation-java/pom.xml
index 3a2dd6daff..0922650a18 100644
--- a/sca-java-2.x/trunk/modules/implementation-java/pom.xml
+++ b/sca-java-2.x/trunk/modules/implementation-java/pom.xml
@@ -43,6 +43,12 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-jaxws</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-interface-wsdl</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/interface-java-jaxws/META-INF/MANIFEST.MF
index ca45f82a45..5c36422a33 100644
--- a/sca-java-2.x/trunk/modules/interface-java-jaxws/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/META-INF/MANIFEST.MF
@@ -38,6 +38,7 @@ Import-Package: javax.jws,
org.apache.tuscany.sca.interfacedef.java.introspect;version="2.0.0",
org.apache.tuscany.sca.interfacedef.java.jaxws;version="2.0.0",
org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
org.apache.tuscany.sca.policy;version="2.0.0",
org.oasisopen.sca;version="2.0.0",
org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional,
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
index c6e4891860..f1ffd6e1d4 100644
--- a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
+++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
@@ -41,6 +41,7 @@ import javax.xml.ws.ResponseWrapper;
import javax.xml.ws.WebServiceProvider;
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.databinding.javabeans.JavaExceptionDataBinding;
@@ -52,6 +53,8 @@ import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
@@ -59,6 +62,7 @@ import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
/**
* Introspect the java class/interface with JSR-181 and JAXWS annotations
@@ -71,22 +75,18 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor {
private DataBindingExtensionPoint dataBindingExtensionPoint;
private FaultExceptionMapper faultExceptionMapper;
private XMLAdapterExtensionPoint xmlAdapterExtensionPoint;
+ protected JavaInterfaceFactory javaInterfaceFactory;
+ private WSDLFactory wsdlFactory;
public JAXWSJavaInterfaceProcessor(ExtensionPointRegistry registry) {
dataBindingExtensionPoint = registry.getExtensionPoint(DataBindingExtensionPoint.class);
faultExceptionMapper = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(FaultExceptionMapper.class);
xmlAdapterExtensionPoint = registry.getExtensionPoint(XMLAdapterExtensionPoint.class);
- }
-
-
- public JAXWSJavaInterfaceProcessor(DataBindingExtensionPoint dataBindingExtensionPoint,
- FaultExceptionMapper faultExceptionMapper,
- XMLAdapterExtensionPoint xmlAdapters) {
- super();
- this.dataBindingExtensionPoint = dataBindingExtensionPoint;
- this.faultExceptionMapper = faultExceptionMapper;
- this.xmlAdapterExtensionPoint = xmlAdapters;
+
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ this.wsdlFactory = factories.getFactory(WSDLFactory.class);
}
public JAXWSJavaInterfaceProcessor() {
@@ -104,8 +104,17 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor {
public void visitInterface(JavaInterface contract) throws InvalidInterfaceException {
final Class<?> clazz = contract.getJavaClass();
- WebService webService = clazz.getAnnotation(WebService.class);
+ contract = JAXWSUtils.configureJavaInterface(contract, clazz);
+ String tns = contract.getQName().getNamespaceURI();
+
+ // TODO - the following code repeats the name determination code in the
+ // utils class. Do name determination separately from interface config.
+ // - determine service name
+ // - determine interface class name
+ // - determine wsdl file name
+/*
+ WebService webService = clazz.getAnnotation(WebService.class);
String tns = JavaXMLMapper.getNamespace(clazz);
String localName = clazz.getSimpleName();
if (webService != null) {
@@ -123,7 +132,8 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor {
contract.setQName(new QName(tns, localName));
// Mark SEI as Remotable
contract.setRemotable(true);
- }
+ }
+*/
if (!contract.isRemotable()) {
return;
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSUtils.java b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSUtils.java
new file mode 100644
index 0000000000..06434cfc11
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSUtils.java
@@ -0,0 +1,310 @@
+/*
+ * 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.interfacedef.java.jaxws;
+
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceProvider;
+
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
+
+
+/**
+ * A set of utility methods for processing JAXWS annotations that are
+ * shared between Java inteface and implementation processing
+ */
+public class JAXWSUtils {
+
+ /**
+ * JAXWS annotations may identify a service interface via either
+ * - an interface class name, e.g. @WebService(endpointInterface="my.service.ServiceImpl")
+ * - a wsdl file name, e.g. @WebService(wsdlLocation="some.wsdl")
+ * - a Java class/interface, e.g. @WebService
+ * This operation configures the Java interface based on these separate pieces
+ * of information. The resulting interface contract must be subsequently resolved in order that
+ * the named endpoint interface class or wsdl file is found
+ *
+ * @param javaInterface the Tuscany representation of the Java interface
+ * @param clazz the Java class that the interface refers to (may have JAXWS annotations)
+ * @return
+ */
+ public static JavaInterface configureJavaInterface(JavaInterface javaInterface,
+ Class<?> clazz){
+
+ String servineNamespace = JavaXMLMapper.getNamespace(clazz);
+ String serviceName = clazz.getSimpleName();
+ QName serviceQName = null;
+ String serviceInterfaceClassName = null;
+ String wsdlFileName = null;
+
+ WebService webServiceAnnotation = clazz.getAnnotation(WebService.class);
+ if (webServiceAnnotation != null) {
+ servineNamespace = getValue(webServiceAnnotation.targetNamespace(), servineNamespace);
+ serviceName = getValue(webServiceAnnotation.name(), serviceName);
+ serviceInterfaceClassName = webServiceAnnotation.endpointInterface();
+ wsdlFileName = webServiceAnnotation.wsdlLocation();
+ javaInterface.setRemotable(true);
+ }
+
+ WebServiceProvider webServiceProviderAnnotation = clazz.getAnnotation(WebServiceProvider.class);
+ if (webServiceProviderAnnotation != null) {
+ servineNamespace = getValue(webServiceProviderAnnotation.targetNamespace(), servineNamespace);
+ serviceName = getValue(webServiceProviderAnnotation.serviceName(), serviceName);
+ wsdlFileName = webServiceAnnotation.wsdlLocation();
+ javaInterface.setRemotable(true);
+ }
+
+ serviceQName = new QName(servineNamespace, serviceName);
+ javaInterface.setQName(serviceQName);
+
+ // use the provided Java interface name to overwrite
+ // any Java interface created from an implemented interfaces
+ if (serviceInterfaceClassName != null &&
+ serviceInterfaceClassName.length() > 0){
+ javaInterface.setName(serviceInterfaceClassName);
+ javaInterface.setJAXWSJavaInterfaceName(serviceInterfaceClassName);
+ javaInterface.setUnresolved(true);
+ }
+
+ // Store the WSDL location if it's specified in
+ // the @WebService annotation. Later this is resolved and is attached
+ // to the Java interface contract in the normalized space so that effectively the contract
+ // has both Java and WSDL interfaces. This allows databinding to
+ // operate correctly as it still expects a Java interface for a Java implementation
+ if (wsdlFileName != null &&
+ wsdlFileName.length() > 0){
+ javaInterface.setJAXWSWSDLLocation(wsdlFileName);
+ }
+
+ return javaInterface;
+ }
+
+ /**
+ * Given a class that may have @WebService or @WebServiceProvider
+ * annotations this determines what the service QName should be.
+ *
+ * @param clazz
+ * @return
+ */
+/*
+ public static QName calculateServiceQName(JavaInterface javaInterface, Class<?> clazz){
+ WebService webServiceAnnotation = clazz.getAnnotation(WebService.class);
+ String servineNamespace = JavaXMLMapper.getNamespace(clazz);
+ String serviceName = clazz.getSimpleName();
+ if (webServiceAnnotation != null) {
+ servineNamespace = getValue(webServiceAnnotation.targetNamespace(), servineNamespace);
+ serviceName = getValue(webServiceAnnotation.name(), serviceName);
+ javaInterface.setRemotable(true);
+ }
+
+ WebServiceProvider webServiceProviderAnnotation = clazz.getAnnotation(WebServiceProvider.class);
+ if (webServiceProviderAnnotation != null) {
+ servineNamespace = getValue(webServiceProviderAnnotation.targetNamespace(), servineNamespace);
+ serviceName = getValue(webServiceProviderAnnotation.serviceName(), serviceName);
+ javaInterface.setRemotable(true);
+ }
+
+ QName serviceQName = new QName(servineNamespace, serviceName);
+ javaInterface.setQName(serviceQName);
+
+ return serviceQName;
+ }
+*/
+
+ /**
+ * Given a class that may have @WebService or @WebServiceProvider
+ * annotations this determines what the name of the Java class
+ * that defines the service interface should be
+ *
+ * @param clazz
+ * @return
+ */
+/*
+ public static String calculateServiceInterfaceJavaClassName(JavaInterface javaInterface, Class<?> clazz){
+ String serviceInterfaceClassName = null;
+
+ WebService webServiceAnnotation = clazz.getAnnotation(WebService.class);
+ if (webServiceAnnotation != null) {
+ serviceInterfaceClassName = webServiceAnnotation.endpointInterface();
+ javaInterface.setRemotable(true);
+ }
+
+ return serviceInterfaceClassName;
+ }
+*/
+
+ /**
+ * Given a class that may have @WebService or @WebServiceProvider
+ * annotations this determines what the name of the WSDL file is
+ * that defines the service interface should be
+ *
+ * @param clazz
+ * @return
+ */
+/*
+ public static String calculateServiceInterfaceWSDLLocation(JavaInterface javaInterface, Class<?> clazz){
+ WebService webServiceAnnotation = clazz.getAnnotation(WebService.class);
+ String wsdlLocation = null;
+
+ if (webServiceAnnotation != null) {
+ wsdlLocation = webServiceAnnotation.wsdlLocation();
+ javaInterface.setRemotable(true);
+ }
+
+ WebServiceProvider webServiceProviderAnnotation = clazz.getAnnotation(WebServiceProvider.class);
+
+ if (webServiceProviderAnnotation != null) {
+ wsdlLocation = webServiceProviderAnnotation.wsdlLocation();
+ javaInterface.setRemotable(true);
+ }
+
+ return wsdlLocation;
+ }
+*/
+
+ /**
+ * JAXWS annotations may identify a service interface via either
+ * - an interface class name, e.g. @WebService(endpointInterface="my.service.ServiceImpl")
+ * - a wsdl file name, e.g. @WebService(wsdlLocation="some.wsdl")
+ * - a Java class/interface, e.g. @WebService
+ * This operation configures the Java interface based on these separate pieces
+ * of information. The resulting interface contract must be subsequently resolved in order that
+ * the named endpoint interface class or wsdl file is found
+ *
+ * @param javaInterface
+ * @param servicceQName
+ * @param javaInterfaceName
+ * @param wsdlFileName
+ * @return
+ */
+/*
+ public static JavaInterface configureJavaInterface(JavaInterface javaInterface,
+ QName serviceQName,
+ String javaInterfaceName,
+ String wsdlFileName) throws InvalidInterfaceException {
+
+ // use the provided Java interface name to overwrite
+ // any Java contract created from an implemented interfaces
+ if (javaInterfaceName != null &&
+ javaInterfaceName.length() > 0){
+ javaInterface.setName(javaInterfaceName);
+ javaInterface.setJAXWSJavaInterfaceName(javaInterfaceName);
+ javaInterface.setQName(serviceQName);
+ javaInterface.setUnresolved(true);
+ } else {
+ // we use the bean class as the service interface if no interface
+ // has already been set. This should have already been resolved
+ javaInterface.setQName(serviceQName);
+ }
+
+ // Store the WSDL location if it's specified in
+ // the @WebService annotation. Later this is resolved and is attached
+ // to the Java interface contract in the normalized space so that effectively the contract
+ // has both Java and WSDL interfaces. This allows databinding to
+ // operate correctly as it still expects a Java interface for a Java implementation
+ if (wsdlFileName != null &&
+ wsdlFileName.length() > 0){
+ javaInterface.setJAXWSWSDLLocation(wsdlFileName);
+ }
+
+ return javaInterface;
+ }
+*/
+
+
+ /**
+ * JAXWS annotations may identify a service interface via either
+ * - an interface class name, e.g. @WebService(endpointInterface="my.service.ServiceImpl")
+ * - a wsdl file name, e.g. @WebService(wsdlLocation="some.wsdl")
+ * - a Java class/interface, e.g. @WebService
+ * This operation creates the right sort of interface contract based on these separate pieces
+ * of information. The resulting interface contract must be subsequently resolved in order that
+ * the named endpoint interface class or wsdl file is found
+ *
+ * @param javaInterfaceFactory
+ * @param wsdlInterfaceFactory
+ * @param clazz
+ * @param javaInterfaceName
+ * @param wsdlFileName
+ * @return
+ * @throws InvalidInterfaceException
+ */
+/*
+ public static JavaInterfaceContract configureJavaInterface(JavaInterfaceFactory javaInterfaceFactory,
+ WSDLFactory wsdlFactory,
+ JavaInterfaceContract javaInterfaceContract,
+ Class<?> clazz,
+ QName serviceQName,
+ String javaInterfaceName,
+ String wsdlFileName) throws InvalidInterfaceException {
+
+ // use the provided Java interface name to overwrite
+ // any Java contract created from an implemented interfaces
+ if (javaInterfaceName != null &&
+ javaInterfaceName.length() > 0){
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface();
+ callInterface.setName(javaInterfaceName);
+ callInterface.setQName(serviceQName);
+ callInterface.setRemotable(true);
+ callInterface.setUnresolved(true);
+ javaInterfaceContract.setInterface(callInterface);
+ } else {
+ // we use the bean class as the service interface if no interface
+ // has already been set
+ if (javaInterfaceContract.getInterface() == null){
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(clazz);
+ callInterface.setQName(serviceQName);
+ callInterface.setRemotable(true);
+ callInterface.setUnresolved(false); // this will already be false but this makes it easy to follow the logic
+ javaInterfaceContract.setInterface(callInterface);
+ } else {
+ JavaInterface callInterface = (JavaInterface)javaInterfaceContract.getInterface();
+ callInterface.setRemotable(true);
+ callInterface.setQName(serviceQName);
+ }
+ }
+
+ // create the logical WSDL interface if it's specified in
+ // the @WebService annotation. This is attached to the Java interface
+ // contract in the normalized space so that effectively the contract
+ // has both Java and WSDL interfaces. This allows databinding to
+ // operate correctly as it expects a Java interface for a Java implementation
+ if (wsdlFileName != null &&
+ wsdlFileName.length() > 0){
+ WSDLInterface callInterface = wsdlFactory.createWSDLInterface();
+ callInterface.setUnresolved(true);
+ callInterface.setRemotable(true);
+
+ WSDLInterfaceContract wsdlInterfaceContract = wsdlFactory.createWSDLInterfaceContract();
+ wsdlInterfaceContract.setInterface(callInterface);
+ wsdlInterfaceContract.setLocation(wsdlFileName);
+ javaInterfaceContract.setNormailizedWSDLContract(wsdlInterfaceContract);
+ }
+
+ return javaInterfaceContract;
+ }
+*/
+
+ private static String getValue(String value, String defaultValue) {
+ return "".equals(value) ? defaultValue : value;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/interface-java/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/interface-java/META-INF/MANIFEST.MF
index 16f285a815..da6bb50c73 100644
--- a/sca-java-2.x/trunk/modules/interface-java/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/interface-java/META-INF/MANIFEST.MF
@@ -23,6 +23,7 @@ Import-Package: javax.xml.namespace,
javax.xml.stream,
org.apache.tuscany.sca.assembly;version="2.0.0",
org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
org.apache.tuscany.sca.contribution.processor;version="2.0.0",
org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
@@ -34,6 +35,7 @@ Import-Package: javax.xml.namespace,
org.apache.tuscany.sca.interfacedef.java.impl;version="2.0.0",
org.apache.tuscany.sca.interfacedef.java.introspect;version="2.0.0",
org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.wsdl;version="2.0.0",
org.apache.tuscany.sca.monitor;version="2.0.0",
org.apache.tuscany.sca.policy;version="2.0.0",
org.oasisopen.sca;version="2.0.0",
diff --git a/sca-java-2.x/trunk/modules/interface-java/pom.xml b/sca-java-2.x/trunk/modules/interface-java/pom.xml
index b5847e2875..22f9234cd3 100644
--- a/sca-java-2.x/trunk/modules/interface-java/pom.xml
+++ b/sca-java-2.x/trunk/modules/interface-java/pom.xml
@@ -52,6 +52,12 @@
<artifactId>tuscany-contribution</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
diff --git a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java
index 8502d4f4e8..9e013746ce 100644
--- a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java
+++ b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java
@@ -43,10 +43,17 @@ import org.apache.tuscany.sca.contribution.resolver.ClassReference;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
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.interfacedef.Compatibility;
+import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
@@ -77,13 +84,20 @@ public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfa
private ExtensionPointRegistry extensionPoints;
private PolicyFactory policyFactory;
private PolicySubjectProcessor policyProcessor;
+ private WSDLFactory wsdlFactory;
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private transient InterfaceContractMapper interfaceContractMapper;
- public JavaInterfaceProcessor(ExtensionPointRegistry extensionPoints) {
+ public JavaInterfaceProcessor(ExtensionPointRegistry extensionPoints, StAXArtifactProcessor<?> staxProcessor) {
this.extensionPoints = extensionPoints;
FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
this.policyProcessor = new PolicySubjectProcessor(policyFactory);
this.javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
+ this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)staxProcessor;
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
}
/**
@@ -212,6 +226,10 @@ public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfa
// Introspect the Java interface and populate the interface and
// operations
javaFactory.createJavaInterface(javaInterface, javaClass);
+
+ // cache the contribution that was used to resolve the Java interface
+ // in case we need it to reolve a referenced WSDL file
+ javaInterface.setContributionContainingClass(classReference.getContributionContainingClass());
} catch (InvalidInterfaceException e) {
ContributionResolveException ce = new ContributionResolveException("Resolving Java interface " + javaInterface.getName(), e);
@@ -243,6 +261,8 @@ public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfa
JavaInterface javaCallbackInterface =
resolveJavaInterface((JavaInterface)javaInterfaceContract.getCallbackInterface(), resolver, context);
javaInterfaceContract.setCallbackInterface(javaCallbackInterface);
+
+ postJAXWSProcessorResolve(javaInterfaceContract, resolver, context);
checkForbiddenAnnotations(monitor, javaInterfaceContract);
@@ -367,4 +387,59 @@ public class JavaInterfaceProcessor implements StAXArtifactProcessor<JavaInterfa
public Class<JavaInterfaceContract> getModelType() {
return JavaInterfaceContract.class;
}
+
+ private void postJAXWSProcessorResolve(JavaInterfaceContract javaInterfaceContract, ModelResolver resolver, ProcessorContext context)
+ throws ContributionResolveException, IncompatibleInterfaceContractException {
+
+ JavaInterface javaInterface = (JavaInterface)javaInterfaceContract.getInterface();
+
+ // the Java interface may now be marked as unresolved due to a new Java interface
+ // name retrieved from JAXWS annotations. Resolve it again if it is.
+ if (javaInterface != null && javaInterface.isUnresolved()){
+ javaInterface = resolveJavaInterface(javaInterface, resolver, context);
+ javaInterfaceContract.setInterface(javaInterface);
+ }
+
+ JavaInterface javaCallbackInterface = (JavaInterface)javaInterfaceContract.getCallbackInterface();
+ // the Java callback interface may now be marked as unresolved due to a new Java interface
+ // name retrieved from JAXWS annotations. Resolve it again if it is.
+ if (javaCallbackInterface != null && javaCallbackInterface.isUnresolved()){
+ javaCallbackInterface = resolveJavaInterface(javaCallbackInterface, resolver, context);
+ javaInterfaceContract.setCallbackInterface(javaCallbackInterface);
+ }
+
+ // the Java interface may be replaced by a WSDL contract picked up from JAXWS annotation
+ // if so we need to fluff up a WSDL contract and set it to be the normalized contract
+ // for the Java interface so it's used during contract mapping
+ if (javaInterface != null && javaInterface.getJAXWSWSDLLocation() != null){
+ WSDLInterface wsdlInterface = wsdlFactory.createWSDLInterface();
+ wsdlInterface.setUnresolved(true);
+ wsdlInterface.setRemotable(true);
+
+ WSDLInterfaceContract wsdlInterfaceContract = wsdlFactory.createWSDLInterfaceContract();
+ wsdlInterfaceContract.setInterface(wsdlInterface);
+ wsdlInterfaceContract.setLocation(javaInterface.getJAXWSWSDLLocation());
+ javaInterfaceContract.setNormailizedWSDLContract(wsdlInterfaceContract);
+
+ ProcessorContext wsdlContext = new ProcessorContext(javaInterface.getContributionContainingClass(),
+ context.getMonitor());
+ extensionProcessor.resolve(wsdlInterfaceContract, resolver, wsdlContext);
+
+ // check that the Java and WSDL contracts are compatible
+ interfaceContractMapper.checkCompatibility(wsdlInterfaceContract,
+ javaInterfaceContract,
+ Compatibility.SUBSET,
+ false,
+ false);
+
+ // copy policy from the WSDL interface to the Java interface
+ javaInterface.getPolicySets().addAll(wsdlInterface.getPolicySets());
+ javaInterface.getRequiredIntents().addAll(wsdlInterface.getRequiredIntents());
+
+ // TODO - is there anything else to be copied from the user specified WSDL?
+
+ }
+
+ // TODO - how to handle callbacks as the location is stored at the contract level?
+ }
}
diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/pom.xml b/sca-java-2.x/trunk/modules/interface-wsdl/pom.xml
index 11dee1a85e..2dfd55644d 100644
--- a/sca-java-2.x/trunk/modules/interface-wsdl/pom.xml
+++ b/sca-java-2.x/trunk/modules/interface-wsdl/pom.xml
@@ -59,12 +59,12 @@
<version>2.0-SNAPSHOT</version>
</dependency>
- <dependency>
+ <!-- dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-sca-runtime</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>test</scope>
- </dependency>
+ </dependency-->
</dependencies>
diff --git a/sca-java-2.x/trunk/modules/node-impl/pom.xml b/sca-java-2.x/trunk/modules/node-impl/pom.xml
index ca708af859..5d55b13fc8 100644
--- a/sca-java-2.x/trunk/modules/node-impl/pom.xml
+++ b/sca-java-2.x/trunk/modules/node-impl/pom.xml
@@ -102,6 +102,13 @@
<version>2.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>