diff options
Diffstat (limited to 'branches/sca-java-1.x/modules')
3 files changed, 55 insertions, 2 deletions
diff --git a/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java b/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java index be80606343..11cff6658f 100644 --- a/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java +++ b/branches/sca-java-1.x/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java @@ -27,10 +27,13 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; +import org.apache.tuscany.sca.assembly.Extension; +import org.apache.tuscany.sca.assembly.ExtensionFactory; import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl; import org.apache.tuscany.sca.assembly.xml.Constants; import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; 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; @@ -53,10 +56,17 @@ import org.apache.tuscany.sca.monitor.Problem.Severity; public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfaceContract>, WSDLConstants { private WSDLFactory wsdlFactory; + private ExtensionFactory extensionFactory; + private StAXAttributeProcessor<Object> extensionAttributeProcessor; private Monitor monitor; - public WSDLInterfaceProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + public WSDLInterfaceProcessor(ModelFactoryExtensionPoint modelFactories, + StAXArtifactProcessor extensionProcessor, + StAXAttributeProcessor extensionAttributeProcessor, + Monitor monitor) { this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class); + this.extensionFactory = modelFactories.getFactory(ExtensionFactory.class); + this.extensionAttributeProcessor = extensionAttributeProcessor; this.monitor = monitor; } @@ -151,6 +161,24 @@ public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfa if (wsdlCallbackInterface != null) wsdlInterfaceContract.setCallbackInterface(wsdlCallbackInterface); } + + // Handle extended attributes + for (int a = 0; a < reader.getAttributeCount(); a++) { + QName attributeName = reader.getAttributeName(a); + if( attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) { + if( (! Constants.SCA10_NS.equals(attributeName.getNamespaceURI()) && + (! Constants.SCA10_TUSCANY_NS.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); + } + wsdlInterfaceContract.getAttributeExtensions().add(attributeExtension); + } + } + } // Skip to end element while (reader.hasNext()) { @@ -185,6 +213,13 @@ public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfa writer.writeAttribute(WSDLI_NS, WSDL_LOCATION, wsdlInterfaceContract.getLocation()); } + // Write extended attributes + for(Extension extension : wsdlInterfaceContract.getAttributeExtensions()) { + if(extension.isAttribute()) { + extensionAttributeProcessor.write(extension, writer); + } + } + writer.writeEndElement(); } diff --git a/branches/sca-java-1.x/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterfaceContract.java b/branches/sca-java-1.x/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterfaceContract.java index 59db17116b..2ef21a50cf 100644 --- a/branches/sca-java-1.x/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterfaceContract.java +++ b/branches/sca-java-1.x/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterfaceContract.java @@ -18,6 +18,7 @@ */ package org.apache.tuscany.sca.interfacedef.wsdl; +import org.apache.tuscany.sca.assembly.Extensible; import org.apache.tuscany.sca.interfacedef.InterfaceContract; @@ -26,7 +27,7 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract; * * @version $Rev$ $Date$ */ -public interface WSDLInterfaceContract extends InterfaceContract { +public interface WSDLInterfaceContract extends InterfaceContract, Extensible { /** * Sets the WSDL location. diff --git a/branches/sca-java-1.x/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java b/branches/sca-java-1.x/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java index e10bc0d178..e116f567c1 100644 --- a/branches/sca-java-1.x/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java +++ b/branches/sca-java-1.x/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java @@ -18,6 +18,10 @@ */ package org.apache.tuscany.sca.interfacedef.wsdl.impl; +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.assembly.Extension; import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractImpl; import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract; @@ -28,6 +32,9 @@ import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract; */ public class WSDLInterfaceContractImpl extends InterfaceContractImpl implements WSDLInterfaceContract { private String location; + private List<Object> extensions = new ArrayList<Object>(); + private List<Extension> attributeExtensions = new ArrayList<Extension>(); + protected WSDLInterfaceContractImpl() { } @@ -39,6 +46,16 @@ public class WSDLInterfaceContractImpl extends InterfaceContractImpl implements public void setLocation(String location) { this.location = location; } + + + public List<Object> getExtensions() { + return extensions; + } + + public List<Extension> getAttributeExtensions() { + return attributeExtensions; + } + @Override public WSDLInterfaceContractImpl clone() throws CloneNotSupportedException { |