diff options
4 files changed, 41 insertions, 4 deletions
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<WebServ private WSDLFactory wsdlFactory; private WebServiceBindingFactory wsFactory; private PolicyFactory policyFactory; + private ExtensionFactory extensionFactory; private PolicyAttachPointProcessor policyProcessor; private IntentAttachPointTypeFactory intentAttachPointTypeFactory; private ConfiguredOperationProcessor configuredOperationProcessor; + private StAXAttributeProcessor<Object> 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<WebServ this.monitor = monitorFactory.createMonitor(); } this.configuredOperationProcessor = new ConfiguredOperationProcessor(modelFactories, this.monitor); + this.extensionAttributeProcessor = extensionPoints.getExtensionPoint(ExtensibleStAXAttributeProcessor.class); } /** @@ -223,6 +233,25 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ // Read wsdlLocation wsBinding.setLocation(reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION)); + + // Handle extended attributes + QName elementName = reader.getName(); + for (int a = 0; a < reader.getAttributeCount(); a++) { + QName attributeName = reader.getAttributeName(a); + if( attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI() != WSDLI_NS && attributeName.getNamespaceURI().length() > 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<WebServ writer.writeAttribute(WSDLI_NS, WSDL_LOCATION, wsBinding.getLocation()); } + for(Extension extension : wsBinding.getAttributeExtensions()) { + if(extension.isAttribute()) { + extensionAttributeProcessor.write(extension, writer); + } + } + if (wsBinding.getEndPointReference() != null) { EndPointReferenceHelper.writeEndPointReference(wsBinding.getEndPointReference(), writer); } diff --git a/branches/sca-java-1.x/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java b/branches/sca-java-1.x/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java index 0e519af9d3..7ab9b19a56 100644 --- a/branches/sca-java-1.x/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java +++ b/branches/sca-java-1.x/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java @@ -27,12 +27,13 @@ import javax.xml.stream.XMLOutputFactory; import junit.framework.TestCase; -import org.apache.tuscany.sca.assembly.ComponentType; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.DefaultStAXAttributeProcessorExtensionPoint; import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint; import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; /** @@ -52,6 +53,7 @@ public class WriteTestCase extends TestCase { inputFactory = XMLInputFactory.newInstance(); outputFactory = XMLOutputFactory.newInstance(); StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints); + StAXAttributeProcessorExtensionPoint staxAttributeProcessors = new DefaultStAXAttributeProcessorExtensionPoint(extensionPoints); staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null); } /* diff --git a/branches/sca-java-1.x/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java b/branches/sca-java-1.x/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java index 0d07a55a14..9e1a261dcf 100644 --- a/branches/sca-java-1.x/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java +++ b/branches/sca-java-1.x/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java @@ -24,6 +24,7 @@ import javax.wsdl.Service; import javax.xml.namespace.QName; import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Extensible; import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; @@ -35,7 +36,7 @@ import org.w3c.dom.Element; * * @version $Rev$ $Date$ */ -public interface WebServiceBinding extends Binding, BindingBuilderExtension { +public interface WebServiceBinding extends Binding, BindingBuilderExtension, Extensible { /** * Sets the WSDL location. diff --git a/branches/sca-java-1.x/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java b/branches/sca-java-1.x/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java index a60376f870..245031f3cb 100644 --- a/branches/sca-java-1.x/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java +++ b/branches/sca-java-1.x/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java @@ -29,7 +29,6 @@ import javax.wsdl.Service; import javax.xml.namespace.QName; import org.apache.tuscany.sca.assembly.ConfiguredOperation; -import org.apache.tuscany.sca.assembly.Extensible; import org.apache.tuscany.sca.assembly.Extension; import org.apache.tuscany.sca.assembly.OperationsConfigurator; import org.apache.tuscany.sca.assembly.builder.BindingBuilder; @@ -49,7 +48,7 @@ import org.w3c.dom.Element; * * @version $Rev$ $Date$ */ -class WebServiceBindingImpl implements WebServiceBinding, PolicySetAttachPoint, Extensible, OperationsConfigurator { +class WebServiceBindingImpl implements WebServiceBinding, PolicySetAttachPoint, OperationsConfigurator { private String name; private String uri; private boolean unresolved; |