summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.3.3/modules/contribution-xml
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-01-17 17:28:17 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-01-17 17:28:17 +0000
commit8324fbee6c8e80e8f46703d88ae82cc4bac417be (patch)
treee745877b135212375bdd938a0067083a64b28588 /branches/sca-java-1.3.3/modules/contribution-xml
parent556f80f1cff817626e735e360b03ffcb598eca2e (diff)
TUSCANY-2463 - Merging latest support for extended attributes from 1.x branch
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@735314 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.3.3/modules/contribution-xml')
-rw-r--r--branches/sca-java-1.3.3/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java39
-rw-r--r--branches/sca-java-1.3.3/modules/contribution-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor19
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