summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-ws/src
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-11-10 09:28:30 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-11-10 09:28:30 +0000
commit3dbc328384ff455cc86f2ad4b7b56ec2b07eb26d (patch)
treeb279698784715c2d03d7c9cf670928900224f3af /sca-java-2.x/trunk/modules/binding-ws/src
parent8dc8673464838ca5ba7599e04af556e1c3f957f2 (diff)
TUSCANY-3975: Apply patch from Rashmi Hunt to fix Missing Extension processing in WebServiceBindingProcessor class
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1200239 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-ws/src')
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java44
1 files changed, 43 insertions, 1 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java b/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
index 61bc805fc1..c9e9e9032d 100644
--- a/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
+++ b/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
@@ -21,7 +21,6 @@ package org.apache.tuscany.sca.binding.ws.xml;
import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
-import static org.apache.tuscany.sca.binding.ws.xml.WebServiceConstants.SCA11_NS;
import java.net.URI;
import java.net.URISyntaxException;
@@ -36,11 +35,16 @@ import javax.wsdl.Service;
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.wsdl.extensions.soap12.SOAP12Address;
import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Extension;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
@@ -50,8 +54,11 @@ import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXAttributeProcessor;
import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
@@ -77,9 +84,12 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem
private WSDLFactory wsdlFactory;
private WebServiceBindingFactory wsFactory;
private PolicyFactory policyFactory;
+ private AssemblyFactory assemblyFactory;
private PolicySubjectProcessor policyProcessor;
//private PolicyFactory intentAttachPointTypeFactory;
private StAXHelper staxHelper;
+ private StAXAttributeProcessor<Object> extensionAttributeProcessor;
+ private ProcessorContext processorContext;
public WebServiceBindingProcessor(ExtensionPointRegistry extensionPoints) {
@@ -88,8 +98,14 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem
this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
this.wsFactory = modelFactories.getFactory(WebServiceBindingFactory.class);
this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
this.policyProcessor = new PolicySubjectProcessor(policyFactory);
staxHelper = StAXHelper.getInstance(extensionPoints);
+ XMLInputFactory inputFactory = extensionPoints.getExtensionPoint(XMLInputFactory.class);
+ XMLOutputFactory outputFactory = extensionPoints.getExtensionPoint(XMLOutputFactory.class);
+ StAXAttributeProcessorExtensionPoint attributeExtensionPoint = extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class);
+ this.extensionAttributeProcessor = new ExtensibleStAXAttributeProcessor(attributeExtensionPoint ,inputFactory, outputFactory);
+ this.processorContext = new ProcessorContext(extensionPoints);
}
/**
@@ -252,6 +268,26 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem
}
}
+ //add binding extensions
+ QName elementName = reader.getName();
+ for (int i = 0; i < reader.getAttributeCount(); i++) {
+ QName attributeName = reader.getAttributeName(i);
+ if(attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) {
+ if(!elementName.getNamespaceURI().equals(attributeName.getNamespaceURI()) ) {
+ Object attributeValue = extensionAttributeProcessor.read(attributeName, reader, processorContext);
+ Extension attributeExtension;
+ if (attributeValue instanceof Extension) {
+ attributeExtension = (Extension)attributeValue;
+ } else {
+ attributeExtension = assemblyFactory.createExtension();
+ attributeExtension.setQName(attributeName);
+ attributeExtension.setValue(attributeValue);
+ attributeExtension.setAttribute(true);
+ }
+ ((Extensible)wsBinding).getAttributeExtensions().add(attributeExtension);
+ }
+ }
+ }
// Skip to end element
while (reader.hasNext()) {
int event = reader.next();
@@ -360,6 +396,12 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem
writer.writeAttribute(WSDLI_NS, WSDL_LOCATION, wsdliLocation.toString());
}
+ // Write extended attributes
+ for(Extension extension : ((Extensible)wsBinding).getAttributeExtensions()) {
+ if(extension.isAttribute()) {
+ extensionAttributeProcessor.write(extension, writer, processorContext);
+ }
+ }
if (wsBinding.getEndPointReference() != null) {
EndPointReferenceHelper.writeEndPointReference(wsBinding.getEndPointReference(), writer, staxHelper);
}