diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-17 01:37:35 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-17 01:37:35 +0000 |
commit | 8d2d28410017a059daed1f4d09419dad554a293a (patch) | |
tree | e958e97fb56ddaed7038907063ecddf745d9f57f /branches/sca-java-1.x/modules/contribution-xml/src/main/java/org/apache/tuscany/sca | |
parent | 6b0cf15e75164724b31bc7194b1663daa6d3268a (diff) |
TUSCANY-2463 - Last adjustments to test processors to support the extension attribute wrapper
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@735201 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/contribution-xml/src/main/java/org/apache/tuscany/sca')
-rw-r--r-- | branches/sca-java-1.x/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/branches/sca-java-1.x/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java b/branches/sca-java-1.x/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java index 36e959ea21..0031063c79 100644 --- a/branches/sca-java-1.x/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java +++ b/branches/sca-java-1.x/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java @@ -23,6 +23,8 @@ 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.contribution.Constants; import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; @@ -38,32 +40,37 @@ import org.apache.tuscany.sca.monitor.Monitor; * * @version $Rev$ $Date$ */ -public class AnyAttributeProcessor extends BaseStAXArtifactProcessor implements StAXAttributeProcessor<String> { - private static final QName ANY_ATTRIBUTE = new QName(Constants.XMLSCHEMA_NS, "anyAttribute"); - - public AnyAttributeProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { - - } +public class AnyAttributeProcessor extends BaseStAXArtifactProcessor implements StAXAttributeProcessor<Extension> { + private static final QName ANY_ATTRIBUTE = new QName(Constants.XMLSCHEMA_NS, "anyAttribute"); + + private ExtensionFactory extensionFactory; + + public AnyAttributeProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + this.extensionFactory = modelFactories.getFactory(ExtensionFactory.class); + } public QName getArtifactType() { return ANY_ATTRIBUTE; } - public Class<String> getModelType() { - return String.class; + public Class<Extension> getModelType() { + return Extension.class; } - public String read(QName attributeName, XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - return reader.getAttributeValue(attributeName.getNamespaceURI(), attributeName.getLocalPart()); + public Extension read(QName attributeName, XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + String attributeValue = reader.getAttributeValue(attributeName.getNamespaceURI(), attributeName.getLocalPart()); + return extensionFactory.createExtension(attributeName, attributeValue, true); } - public void write(String value, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - writer.setPrefix(ANY_ATTRIBUTE.getPrefix(), ANY_ATTRIBUTE.getNamespaceURI()); - writer.writeAttribute(ANY_ATTRIBUTE.getLocalPart(), value); + public void write(Extension attributeExtension, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + writer.writeAttribute(attributeExtension.getQName().getPrefix(), + attributeExtension.getQName().getNamespaceURI(), + attributeExtension.getQName().getLocalPart(), + attributeExtension.getValue().toString()); //for extended attributes, we can assume values + // are just the string representation fo the attribute } - - public void resolve(String arg0, ModelResolver arg1) throws ContributionResolveException { + public void resolve(Extension arg0, ModelResolver arg1) throws ContributionResolveException { } } |