diff options
Diffstat (limited to 'branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java')
-rw-r--r-- | branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java index 80c5e807fe..e7aa06755b 100644 --- a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java +++ b/branches/sca-java-1.3.3/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; @@ -103,16 +106,18 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implement /** * Constructs a new BaseArtifactProcessor. * @param contribFactory - * @param factory + * @param assemblyFactory * @param policyFactory */ @SuppressWarnings("unchecked") public BaseAssemblyProcessor(ContributionFactory contribFactory, - AssemblyFactory factory, + 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.contributionFactory = contribFactory; @@ -123,21 +128,21 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implement /** * Constructs a new BaseArtifactProcessor. - * @param factory + * @param assemblyFactory * @param policyFactory */ @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. } /** @@ -856,6 +861,7 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implement } } + /** * * @param reader @@ -866,15 +872,21 @@ 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()) ) { + Object attributeValue = extensionAttributeProcessor.read(attributeName, reader); + Extension attributeExtension; + if (attributeValue instanceof Extension) { + attributeExtension = (Extension) attributeValue; + } else { + attributeExtension = extensionFactory.createExtension(attributeName, attributeValue, true); + } + estensibleElement.getAttributeExtensions().add(attributeExtension); + } + } + } } @@ -888,11 +900,10 @@ 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, writer); + } } } |