diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-23 15:23:36 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-23 15:23:36 +0000 |
commit | f70779f22413d65ac296f05b57704c2e97a3fb34 (patch) | |
tree | a4f4599e4e5a5a80e1540cbc43cf2f8625fc02c0 /branches/sca-java-1.3.2/modules/contribution-xml | |
parent | b98c56ffb2cc0b9b0c17877163a0f1edac6a9a45 (diff) |
TUSCANY-2538 - Merging updates from trunk
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@698203 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | branches/sca-java-1.3.2/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java | 69 | ||||
-rw-r--r-- | branches/sca-java-1.3.2/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java (renamed from branches/sca-java-1.3.2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultUnknownElementProcessor.java) | 59 | ||||
-rw-r--r-- | branches/sca-java-1.3.2/modules/contribution-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor | 1 |
3 files changed, 119 insertions, 10 deletions
diff --git a/branches/sca-java-1.3.2/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java b/branches/sca-java-1.3.2/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java new file mode 100644 index 0000000000..36e959ea21 --- /dev/null +++ b/branches/sca-java-1.3.2/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java @@ -0,0 +1,69 @@ +/* + * 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. + */ +package org.apache.tuscany.sca.contribution.processor.xml; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.contribution.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +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; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.monitor.Monitor; + +/** + * A Policy Processor used for testing. + * + * @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 QName getArtifactType() { + return ANY_ATTRIBUTE; + } + + public Class<String> getModelType() { + return String.class; + } + + public String read(QName attributeName, XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + return reader.getAttributeValue(attributeName.getNamespaceURI(), attributeName.getLocalPart()); + } + + 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 resolve(String arg0, ModelResolver arg1) throws ContributionResolveException { + + } +} diff --git a/branches/sca-java-1.3.2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultUnknownElementProcessor.java b/branches/sca-java-1.3.2/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java index d52a110c05..66bea7a4dd 100644 --- a/branches/sca-java-1.3.2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultUnknownElementProcessor.java +++ b/branches/sca-java-1.3.2/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java @@ -1,4 +1,22 @@ -package org.apache.tuscany.sca.contribution.processor; +/* + * 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. + */ +package org.apache.tuscany.sca.contribution.processor.xml; import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; @@ -15,6 +33,12 @@ import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl; +import org.apache.tuscany.sca.contribution.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.Problem; import org.apache.tuscany.sca.monitor.Problem.Severity; @@ -27,17 +51,28 @@ import org.w3c.dom.traversal.NodeFilter; import org.w3c.dom.traversal.NodeIterator; import org.w3c.dom.traversal.TreeWalker; -public class DefaultUnknownElementProcessor{ +public class AnyElementProcessor implements StAXArtifactProcessor<Object> { + private static final QName ANY_ELEMENT = new QName(Constants.XMLSCHEMA_NS, "anyElement"); + private static final Logger logger = Logger.getLogger(AnyElementProcessor.class.getName()); + private DocumentBuilderFactory documentBuilderFactory; + private Document document; private Monitor monitor; - private static final Logger logger = Logger.getLogger(DefaultUnknownElementProcessor.class.getName()); - public DefaultUnknownElementProcessor(Monitor monitor){ + public AnyElementProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); this.monitor = monitor; } - private DocumentBuilderFactory documentBuilderFactory; - private Document document; + + public QName getArtifactType() { + return ANY_ELEMENT; + } + + public Class<Object> getModelType() { + return Object.class; + } + /** * Reads the contetns of the unknown elements and generates the DOM * @param reader @@ -45,12 +80,15 @@ public class DefaultUnknownElementProcessor{ * @return * @throws XMLStreamException */ - public Object read(XMLStreamReader reader, QName name) throws XMLStreamException{ + public Object read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { int event = reader.getEventType(); int level = 0; ArrayList<String> elementList = new ArrayList<String>(); document = createDocument(); + + QName name = reader.getName(); + while(reader.hasNext()){ switch(event){ case START_ELEMENT: @@ -105,6 +143,10 @@ public class DefaultUnknownElementProcessor{ } } + public void resolve(Object arg0, ModelResolver arg1) throws ContributionResolveException { + + } + /** * Method to generate the DOM * @param reader @@ -172,9 +214,6 @@ public class DefaultUnknownElementProcessor{ */ private Document createDocument() { try { - if (documentBuilderFactory == null) { - documentBuilderFactory = DocumentBuilderFactory.newInstance(); - } document = documentBuilderFactory.newDocumentBuilder().newDocument(); return document; } catch (ParserConfigurationException e) { diff --git a/branches/sca-java-1.3.2/modules/contribution-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-1.3.2/modules/contribution-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor index b73c380370..b69ea1e135 100644 --- a/branches/sca-java-1.3.2/modules/contribution-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ b/branches/sca-java-1.3.2/modules/contribution-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -17,3 +17,4 @@ # Implementation class for the artifact processor extension org.apache.tuscany.sca.contribution.xml.ContributionMetadataProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#contribution,model=org.apache.tuscany.sca.contribution.ContributionMetadata +org.apache.tuscany.sca.contribution.processor.xml.AnyElementProcessor;qname=http://www.w3.org/2001/XMLSchema#anyElement,model=java.lang.Object |