diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-17 01:27:23 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-17 01:27:23 +0000 |
commit | 558e63a849e90059c16a8834f87b8c39b629b237 (patch) | |
tree | 6642696ecdd62d78e4e66b9dd2c10ce972ef54af /branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java | |
parent | cbb14b9965208792bdba2f313bc57951c90c1a12 (diff) |
TUSCANY-2463 - Storing extended attributes in a second list, wrapped into a extension class that stores the attribute QName, it's value
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@735197 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java')
-rw-r--r-- | branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java index 80c5e807fe..ac9f4c6006 100644 --- a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java +++ b/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java @@ -50,6 +50,8 @@ import org.apache.tuscany.sca.assembly.ConfiguredOperation; import org.apache.tuscany.sca.assembly.ConstrainingType; import org.apache.tuscany.sca.assembly.Contract; import org.apache.tuscany.sca.assembly.Extensible; +import org.apache.tuscany.sca.assembly.Extension; +import org.apache.tuscany.sca.assembly.ExtensionFactory; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Multiplicity; import org.apache.tuscany.sca.assembly.OperationsConfigurator; @@ -93,6 +95,7 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implement protected ContributionFactory contributionFactory; protected AssemblyFactory assemblyFactory; + protected ExtensionFactory extensionFactory; protected PolicyFactory policyFactory; protected StAXArtifactProcessor<Object> extensionProcessor; protected PolicyAttachPointProcessor policyProcessor; @@ -100,44 +103,53 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implement protected IntentAttachPointTypeFactory intentAttachPointTypeFactory; private Monitor monitor; + /** * Constructs a new BaseArtifactProcessor. * @param contribFactory - * @param factory + * @param assemblyFactory + * @param extensionFactory * @param policyFactory + * @param extensionProcessor + * @param monitor */ @SuppressWarnings("unchecked") public BaseAssemblyProcessor(ContributionFactory contribFactory, - AssemblyFactory factory, + AssemblyFactory assemblyFactory, + ExtensionFactory extensionFactory, PolicyFactory policyFactory, StAXArtifactProcessor extensionProcessor, Monitor monitor) { - this.assemblyFactory = factory; + this.contributionFactory = contribFactory; + this.assemblyFactory = assemblyFactory; + this.extensionFactory = extensionFactory; this.policyFactory = policyFactory; this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor; - this.contributionFactory = contribFactory; this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); this.intentAttachPointTypeFactory = new IntentAttachPointTypeFactoryImpl(); this.monitor = monitor; } /** - * Constructs a new BaseArtifactProcessor. - * @param factory + * Constructs a new BaseArtifactProcessor. + * @param assemblyfactory + * @param extensionFactory * @param policyFactory + * @param extensionProcessor + * @param monitor */ @SuppressWarnings("unchecked") - public BaseAssemblyProcessor(AssemblyFactory factory, + public BaseAssemblyProcessor(AssemblyFactory assemblyfactory, + ExtensionFactory extensionFactory, PolicyFactory policyFactory, StAXArtifactProcessor extensionProcessor, Monitor monitor) { - this.assemblyFactory = factory; + this.assemblyFactory = assemblyfactory; + this.extensionFactory = extensionFactory; this.policyFactory = policyFactory; this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor; this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); this.monitor = monitor; - - //TODO - this constructor should take a monitor too. } /** @@ -866,15 +878,16 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implement * @throws XMLStreamException */ protected void readExtendedAttributes(XMLStreamReader reader, QName elementName, Extensible estensibleElement, StAXAttributeProcessor extensionAttributeProcessor) throws ContributionReadException, XMLStreamException { - for (int a = 0; a < reader.getAttributeCount(); a++) { - QName attributeName = reader.getAttributeName(a); - if( attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) { - if( ! elementName.getNamespaceURI().equals(attributeName.getNamespaceURI()) ) { - String attributeExtension = (String) extensionAttributeProcessor.read(attributeName, reader); - estensibleElement.getExtensions().add(attributeExtension); - } - } - } + for (int a = 0; a < reader.getAttributeCount(); a++) { + QName attributeName = reader.getAttributeName(a); + if( attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) { + if( ! elementName.getNamespaceURI().equals(attributeName.getNamespaceURI()) ) { + String attributeValue = (String) extensionAttributeProcessor.read(attributeName, reader); + Extension attributeExtension = extensionFactory.createExtension(attributeName, attributeValue, true); + estensibleElement.getAttributeExtensions().add(attributeExtension); + } + } + } } @@ -888,14 +901,13 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implement * @throws XMLStreamException */ protected void writeExtendedAttributes(XMLStreamWriter writer, Extensible extensibleElement, StAXAttributeProcessor extensionAttributeProcessor) throws ContributionWriteException, XMLStreamException { - for(Object o : extensibleElement.getExtensions()) { - //FIXME How to identify it's a extended attribute ? - if(o instanceof String) { - extensionAttributeProcessor.write(o, writer); - } + for(Extension extension : extensibleElement.getAttributeExtensions()) { + if(extension.isAttribute()) { + extensionAttributeProcessor.write(extension.getValue(), writer); + } } } - + /*protected void validatePolicySets(PolicySetAttachPoint policySetAttachPoint) throws ContributionResolveException { validatePolicySets(policySetAttachPoint, policySetAttachPoint.getApplicablePolicySets()); |