diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-08-12 09:29:25 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-08-12 09:29:25 +0000 |
commit | 2fa7aa6f0fd5a5f50f3971bc14c1c58d2a7f263f (patch) | |
tree | c63b4c80e8323ec01949cbac9355d96a4dd09fa6 /sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca | |
parent | d89457df724ae0ab598a9e31c2d48845cddc233b (diff) |
TUSCANY-3641 - When a JAXWS binding is encountered make sure that the associated SCA service has a WS binding.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@984702 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca')
-rw-r--r-- | sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessor.java | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessor.java b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessor.java index d2678bf93e..71a582e67f 100644 --- a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessor.java +++ b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JAXWSProcessor.java @@ -32,6 +32,9 @@ import javax.xml.ws.WebServiceProvider; import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+import org.apache.tuscany.sca.binding.ws.xml.WebServiceConstants;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
@@ -47,6 +50,7 @@ import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper; 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.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySubject;
@@ -59,6 +63,7 @@ public class JAXWSProcessor extends BaseJavaClassVisitor { private PolicyFactory policyFactory;
private WSDLFactory wsdlFactory;
+ private WebServiceBindingFactory wsBindingFactory;
public JAXWSProcessor(ExtensionPointRegistry registry) {
super(registry);
@@ -67,14 +72,18 @@ public class JAXWSProcessor extends BaseJavaClassVisitor { this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
this.policyFactory = factories.getFactory(PolicyFactory.class);
this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ this.wsBindingFactory = factories.getFactory(WebServiceBindingFactory.class);
}
@Override
public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+ boolean hasJaxwsAnnotation = false;
+
// Process @ServiceMode annotation - JCA 11013
if ( clazz.getAnnotation(ServiceMode.class) != null ) {
addSOAPIntent(type);
+ hasJaxwsAnnotation = true;
}
// Process @WebService annotation - POJO_8029, POJO_8030
@@ -95,6 +104,7 @@ public class JAXWSProcessor extends BaseJavaClassVisitor { } catch (InvalidInterfaceException e) {
throw new IntrospectionException(e);
}
+ hasJaxwsAnnotation = true;
}
// Process @WebServiceProvider annotation - JCA_11015, POJO_8034
@@ -127,6 +137,8 @@ public class JAXWSProcessor extends BaseJavaClassVisitor { for ( Service service : type.getServices() ) {
service.getInterfaceContract().getInterface().setRemotable(true);
}
+
+ hasJaxwsAnnotation = true;
}
// Process @WebParam and @WebResult annotations - POJO_8031, POJO_8032
@@ -170,6 +182,7 @@ public class JAXWSProcessor extends BaseJavaClassVisitor { if (hasHeaderParam){
// Add a SOAP intent to the service
addSOAPIntent(service);
+ hasJaxwsAnnotation = true;
}
}
@@ -180,7 +193,18 @@ public class JAXWSProcessor extends BaseJavaClassVisitor { for ( Service service : type.getServices() ) {
addSOAPIntent(service);
}
+ hasJaxwsAnnotation = true;
}
+
+ if (hasJaxwsAnnotation == true){
+ // Note that services are based on JAXWS annotations so
+ // that during the build process a binding.ws can be added
+ // if required
+ for ( Service service : type.getServices() ) {
+ service.setJAXWSService(true);
+ createWSBinding(type, service);
+ }
+ }
}
/**
@@ -191,7 +215,7 @@ public class JAXWSProcessor extends BaseJavaClassVisitor { return "".equals(value) ? defaultValue : value;
}
- public Service createService(JavaImplementation type, Class<?> clazz, String serviceName, String javaInterfaceName, String wsdlFileName, boolean replace) throws InvalidInterfaceException, IntrospectionException {
+ private Service createService(JavaImplementation type, Class<?> clazz, String serviceName, String javaInterfaceName, String wsdlFileName, boolean replace) throws InvalidInterfaceException, IntrospectionException {
Service service = assemblyFactory.createService();
if (serviceName != null) {
@@ -269,5 +293,16 @@ public class JAXWSProcessor extends BaseJavaClassVisitor { soapIntent.setName(Constants.SOAP_INTENT);
policySubject.getRequiredIntents().add(soapIntent);
}
+
+ private void createWSBinding(JavaImplementation javaImplementation, Service service){
+ if(service.getBindings().size() == 0){
+ WebServiceBinding wsBinding = wsBindingFactory.createWebServiceBinding();
+ ExtensionType bindingType = policyFactory.createBindingType();
+ bindingType.setType(WebServiceConstants.BINDING_WS_QNAME);
+ bindingType.setUnresolved(true);
+ ((PolicySubject)wsBinding).setExtensionType(bindingType);
+ service.getBindings().add(wsBinding);
+ }
+ }
}
|