diff options
Diffstat (limited to 'branches/sca-equinox/modules/contribution/src/main')
4 files changed, 43 insertions, 22 deletions
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java index ce706fa69c..a1c13c95f2 100644 --- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java +++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java @@ -34,6 +34,7 @@ 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.resolver.ModelResolver; import org.apache.tuscany.sca.contribution.service.ContributionReadException; import org.apache.tuscany.sca.contribution.service.ContributionResolveException; @@ -51,10 +52,11 @@ import org.apache.tuscany.sca.monitor.Problem.Severity; * * @version $Rev$ $Date$ */ -public class ExtensibleStAXArtifactProcessor - implements StAXArtifactProcessor<Object> { - +public class ExtensibleStAXArtifactProcessor implements StAXArtifactProcessor<Object> { private static final Logger logger = Logger.getLogger(ExtensibleStAXArtifactProcessor.class.getName()); + + private static final QName ANY_ELEMENT = new QName("http://www.w3.org/2001/XMLSchema", "anyElement"); + private XMLInputFactory inputFactory; private XMLOutputFactory outputFactory; private StAXArtifactProcessorExtensionPoint processors; @@ -138,7 +140,13 @@ public class ExtensibleStAXArtifactProcessor logger.warning("Element " + name + " cannot be processed. (" + location + ")"); } warning("ElementCannotBeProcessed", processors, name, location); - return null; + + StAXArtifactProcessor<?> anyElementProcessor = processors.getProcessor(ANY_ELEMENT); + if (anyElementProcessor != null) { + return anyElementProcessor.read(source); + } else { + return null; + } } return processor.read(source); } @@ -156,6 +164,11 @@ public class ExtensibleStAXArtifactProcessor logger.warning("No StAX processor is configured to handle " + model.getClass()); } warning("NoStaxProcessor", processors, model.getClass()); + + StAXArtifactProcessor anyElementProcessor = processors.getProcessor(ANY_ELEMENT); + if (anyElementProcessor != null) { + anyElementProcessor.write(model, outputSource); + } } } } diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java index 3329f0bf1c..29c2af7513 100644 --- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java +++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java @@ -147,6 +147,17 @@ public class ExtensibleStAXAttributeProcessor return processor.read(attributeName, source); } + + //handle extension attributes without processors + processor = (StAXAttributeProcessor<?>)processors.getProcessor(UNKNOWN_ATTRIBUTE); + if (processor == null) { + Location location = source.getLocation(); + if (logger.isLoggable(Level.WARNING)) { + logger.warning("Could not find Default Attribute processor !"); + } + warning("DefaultAttributeProcessorNotAvailable", processors, UNKNOWN_ATTRIBUTE, location); + } + return processor == null ? null : processor.read(attributeName, source); } @@ -168,6 +179,18 @@ public class ExtensibleStAXAttributeProcessor processor.write(model, outputSource); return; } + + //handle extension attributes without processors + processor = (StAXAttributeProcessor<?>)processors.getProcessor(UNKNOWN_ATTRIBUTE); + if(processor == null) { + if (logger.isLoggable(Level.WARNING)) { + logger.warning("No Default StAX processor is configured to handle " + model.getClass()); + } + warning("NoDefaultStaxProcessor", processors, model.getClass()); + } else { + processor.write(model, outputSource); + return; + } } diff --git a/branches/sca-equinox/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint b/branches/sca-equinox/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint deleted file mode 100644 index 607725bcfe..0000000000 --- a/branches/sca-equinox/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint +++ /dev/null @@ -1,18 +0,0 @@ -# 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.
-
-org.apache.tuscany.sca.contribution.processor.DefaultStAXAttributeProcessorExtensionPoint
diff --git a/branches/sca-equinox/modules/contribution/src/main/resources/contribution-validation-messages.properties b/branches/sca-equinox/modules/contribution/src/main/resources/contribution-validation-messages.properties index bd650fe457..4f9f85048e 100644 --- a/branches/sca-equinox/modules/contribution/src/main/resources/contribution-validation-messages.properties +++ b/branches/sca-equinox/modules/contribution/src/main/resources/contribution-validation-messages.properties @@ -23,9 +23,12 @@ SchemaFatalError = XMLSchema validation fatal error occured in: {0} ,line = {1}, SchemaWarning = XMLSchema validation warning occured in: {0} ,line = {1}, column = {2}, Message = {3} UnsupportedPackageTypeException = Unsupported contribution package type: {0} ElementCannotBeProcessed = Element {0} cannot be processed. ({1}) +AttributeCannotBeProcessed = Attribute {0} cannot be processed. ({1}) NoStaxProcessor = No StAX processor is configured to handle {0} ContributionWriteException = ContributionWriteException occured due to : ContributionReadException = ContributionReadException occured due to : UnrecognizedElementException = Unrecognized Element : {0} IllegalArgumentException = Invalid qname: {0} PrivilegedActionException = PrivilegedActionException occured due to : +AttributeCannotBeProcessed = Attribute {0} cannot be processed. ({1}) + |