summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules/binding-ws-xml
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-01-29 00:57:03 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-01-29 00:57:03 +0000
commit70e869a4084bf447e9a030918acfa4e13e5b768a (patch)
treed2019d10aaa17ca0575c3ad1cbe366c4ff247290 /branches/sca-java-1.x/modules/binding-ws-xml
parent5a491c61ea56c68917b4a267b8a289f12d3a230f (diff)
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
Diffstat (limited to 'branches/sca-java-1.x/modules/binding-ws-xml')
-rw-r--r--branches/sca-java-1.x/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java35
-rw-r--r--branches/sca-java-1.x/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java4
2 files changed, 38 insertions, 1 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);
}
/*