From 70e869a4084bf447e9a030918acfa4e13e5b768a Mon Sep 17 00:00:00 2001 From: lresende Date: Thu, 29 Jan 2009 00:57:03 +0000 Subject: Adding support for extended attributes to webservices binding git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@738685 13f79535-47bb-0310-9956-ffa450edef68 --- .../binding/ws/xml/WebServiceBindingProcessor.java | 35 ++++++++++++++++++++++ .../tuscany/sca/binding/ws/xml/WriteTestCase.java | 4 ++- 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'branches/sca-java-1.x/modules/binding-ws-xml') diff --git a/branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java b/branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java index 980003ddf1..7da20dafb7 100644 --- a/branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java +++ b/branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java @@ -23,6 +23,7 @@ import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; import java.util.Map; + import javax.wsdl.Binding; import javax.wsdl.Port; import javax.wsdl.PortType; @@ -33,6 +34,8 @@ import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; import org.apache.tuscany.sca.assembly.ConfiguredOperation; +import org.apache.tuscany.sca.assembly.Extension; +import org.apache.tuscany.sca.assembly.ExtensionFactory; import org.apache.tuscany.sca.assembly.OperationsConfigurator; import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl; import org.apache.tuscany.sca.assembly.xml.ConfiguredOperationProcessor; @@ -42,7 +45,9 @@ import org.apache.tuscany.sca.binding.ws.DefaultWebServiceBindingFactory; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXAttributeProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; import org.apache.tuscany.sca.contribution.service.ContributionReadException; import org.apache.tuscany.sca.contribution.service.ContributionResolveException; @@ -74,17 +79,21 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor extensionAttributeProcessor; private Monitor monitor; public WebServiceBindingProcessor(ExtensionPointRegistry extensionPoints) { + this.extensionPoints = extensionPoints; ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); this.policyFactory = modelFactories.getFactory(PolicyFactory.class); this.wsFactory = new DefaultWebServiceBindingFactory(); this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class); + this.extensionFactory = modelFactories.getFactory(ExtensionFactory.class); this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); this.intentAttachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class); UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); @@ -93,6 +102,7 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor 0) { + if( ! elementName.getNamespaceURI().equals(attributeName.getNamespaceURI()) ) { + Object attributeValue = extensionAttributeProcessor.read(attributeName, reader); + Extension attributeExtension; + if (attributeValue instanceof Extension) { + attributeExtension = (Extension) attributeValue; + } else { + attributeExtension = extensionFactory.createExtension(attributeName, attributeValue, true); + } + wsBinding.getAttributeExtensions().add(attributeExtension); + } + } + } + ConfiguredOperation confOp = null; // Skip to end element @@ -322,6 +351,12 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor