From 959ac6c9a2ce735b02a2f9fb75234326423695ad Mon Sep 17 00:00:00 2001 From: slaws Date: Thu, 1 Dec 2011 16:45:57 +0000 Subject: Add a mechanism for specifying default intents on policy subjects. This is a rewrite of the previous attempt after Greg pointed out a build order issue on the mail list. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1209146 13f79535-47bb-0310-9956-ffa450edef68 --- .../ws/wsdlgen/WebServiceBindingBuilder.java | 56 +++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main') 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 08f8ce7cf4..211e7647d9 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 @@ -19,8 +19,11 @@ package org.apache.tuscany.sca.binding.ws.wsdlgen; +import java.util.List; + import javax.xml.namespace.QName; +import org.apache.tuscany.sca.assembly.Base; import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.Contract; import org.apache.tuscany.sca.assembly.builder.BindingBuilder; @@ -30,6 +33,8 @@ 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.DefaultingPolicySubject; +import org.apache.tuscany.sca.policy.DefaultIntent; import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.PolicyFactory; import org.apache.tuscany.sca.policy.PolicySubject; @@ -42,9 +47,13 @@ import org.apache.tuscany.sca.policy.PolicySubject; public class WebServiceBindingBuilder implements BindingBuilder { private ExtensionPointRegistry extensionPoints; + private PolicyFactory policyFactory; public WebServiceBindingBuilder(ExtensionPointRegistry extensionPoints) { this.extensionPoints = extensionPoints; + + FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); + this.policyFactory = modelFactories.getFactory(PolicyFactory.class); } /** @@ -67,7 +76,51 @@ public class WebServiceBindingBuilder implements BindingBuilder defaultIntents = ((DefaultingPolicySubject)binding).getDefaultIntents(); + DefaultIntent defaultIntent = policyFactory.createDefaultIntent(); + + Definitions systemDefinitions = context.getDefinitions(); + if (systemDefinitions != null){ + BindingType bindingType = systemDefinitions.getBindingType(binding.getType()); + for (Intent mayProvideIntent : bindingType.getMayProvidedIntents()){ + if (mayProvideIntent.getName().getLocalPart().equals("SOAP.v1_1")){ + defaultIntent.setIntent(mayProvideIntent); + } + if (mayProvideIntent.getName().getLocalPart().equals("SOAP.v1_2")){ + defaultIntent.getMutuallyExclusiveIntents().add(mayProvideIntent); + } + } + + defaultIntents.add(defaultIntent); + } + + // if the binding may provide SOAP.v1_1 then use this is as the default if no + // other intents are specified +/* + if (intent != null){ + List defaultIntents = ((DefaultingPolicySubject)binding).getDefaultIntents(); + DefaultIntent defaultIntent = policyFactory.createDefaultIntent(); + + // Add the default intent + defaultIntent.setDefaultIntent(intent); + + // Add the names of all of the intents that must not be present in + // order for the default intent to come into force + defaultIntent.getMutuallyExclusiveIntents().add(new QName(Base.SCA11_NS, "SOAP.v1_1")); + defaultIntent.getMutuallyExclusiveIntents().add(new QName(Base.SCA11_NS, "SOAP.v1_2")); + defaultIntent.getMutuallyExclusiveIntents().add(new QName(Base.SCA11_NS, "SOAP")); + + defaultIntents.add(defaultIntent); + } +*/ + +/* boolean addDefaultSOAPIntent = true; for(Intent intent : ((PolicySubject)binding).getRequiredIntents()){ @@ -97,6 +150,7 @@ public class WebServiceBindingBuilder implements BindingBuilder