diff options
Diffstat (limited to 'branches/sca-java-1.3.3/modules/contribution-xml')
2 files changed, 42 insertions, 16 deletions
diff --git a/branches/sca-java-1.3.3/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java b/branches/sca-java-1.3.3/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java index 36e959ea21..e4f9a1180a 100644 --- a/branches/sca-java-1.3.3/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java +++ b/branches/sca-java-1.3.3/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 { } -} +}
\ No newline at end of file diff --git a/branches/sca-java-1.3.3/modules/contribution-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor b/branches/sca-java-1.3.3/modules/contribution-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor new file mode 100644 index 0000000000..b4a13295bc --- /dev/null +++ b/branches/sca-java-1.3.3/modules/contribution-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the attribute processor extension +org.apache.tuscany.sca.contribution.processor.xml.AnyAttributeProcessor;qname=http://www.w3.org/2001/XMLSchema#anyAttribute,model=org.apache.tuscany.sca.assembly.Extension |