summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-10-19 08:37:03 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-10-19 08:37:03 +0000
commitcd0530f3d5222a020ac1ffae2956018402d36adf (patch)
tree27257b651ea8181166cf492f45380e8794fd720f /sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src
parent3312769c458a55a8420566eff6936957a7c1e645 (diff)
Add code to read <requires> elements from WSDL and enable the test that ensure that mayProvides intents are matched between references and services. This has implications for existing tests in that we now have to ensure that any mayProvides intent that is considered to be the default (a concept that the spec doesn't consider) is present in the intent list for the policy subject in question.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1186027 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src')
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java
index 2b24df92d2..08f8ce7cf4 100644
--- a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java
+++ b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java
@@ -27,6 +27,12 @@ import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
import org.apache.tuscany.sca.assembly.builder.BuilderContext;
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.definitions.Definitions;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* A factory for the calculated WSDL document needed by Web Service bindings.
@@ -52,7 +58,46 @@ public class WebServiceBindingBuilder implements BindingBuilder<WebServiceBindin
binding.setBindingInterfaceContract(null);
binding.setGeneratedWSDLDocument(null);
}
+
BindingWSDLGenerator.generateWSDL(component, contract, binding, extensionPoints, context.getMonitor());
+
+ /*
+ * Set the default mayProvides intent provided by the binding. For example,
+ * It mayProvides SOAP.v1_1 and SOAP.v1_2. If you don't specify any intents
+ * it implements SOAP.v1_1 by default and hence the default intent
+ * is SOAP.v1_1. Binding.ws doesn't allwaysProvide SOAP.v1_1 though as if the
+ * user specifies the SOAP.v1_2 the binding does SOAP.v1_2 instead of SOAP.v1_1
+ */
+ boolean addDefaultSOAPIntent = true;
+
+ for(Intent intent : ((PolicySubject)binding).getRequiredIntents()){
+ if (intent.getName().getLocalPart().equals("SOAP.v1_1")){
+ addDefaultSOAPIntent = false;
+ break;
+ }
+ if (intent.getName().getLocalPart().equals("SOAP.v1_2")){
+ addDefaultSOAPIntent = false;
+ break;
+ }
+ }
+
+ if (addDefaultSOAPIntent){
+ Definitions systemDefinitions = context.getDefinitions();
+ if (systemDefinitions != null){
+ BindingType bindingType = systemDefinitions.getBindingType(binding.getType());
+ Intent defaultIntent = null;
+ for (Intent intent : bindingType.getMayProvidedIntents()){
+ if (intent.getName().getLocalPart().equals("SOAP.v1_1")){
+ defaultIntent = intent;
+ }
+ }
+
+ if (defaultIntent != null){
+ ((PolicySubject)binding).getRequiredIntents().add(0, defaultIntent);
+ }
+ }
+ }
+
}
public QName getBindingType() {