diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-17 17:28:17 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-17 17:28:17 +0000 |
commit | 8324fbee6c8e80e8f46703d88ae82cc4bac417be (patch) | |
tree | e745877b135212375bdd938a0067083a64b28588 /branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache | |
parent | 556f80f1cff817626e735e360b03ffcb598eca2e (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/assembly-xml/src/main/java/org/apache')
8 files changed, 73 insertions, 44 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); + } } } diff --git a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java index b07c91d1b3..ec355e069e 100644 --- a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java +++ b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java @@ -56,7 +56,7 @@ public class ComponentTypeDocumentProcessor extends BaseAssemblyProcessor implem public ComponentTypeDocumentProcessor(StAXArtifactProcessor staxProcessor, XMLInputFactory inputFactory, Monitor monitor) { - super(null, null, staxProcessor, monitor); + super(null, null, null, staxProcessor, monitor); this.inputFactory = inputFactory; } @@ -68,7 +68,7 @@ public class ComponentTypeDocumentProcessor extends BaseAssemblyProcessor implem public ComponentTypeDocumentProcessor(ModelFactoryExtensionPoint modelFactories, StAXArtifactProcessor staxProcessor, Monitor monitor) { - super(null, null, staxProcessor, monitor); + super(null, null, null, staxProcessor, monitor); this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class); } diff --git a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java index 07e1507449..7a95062ff0 100644 --- a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java +++ b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java @@ -33,6 +33,7 @@ import org.apache.tuscany.sca.assembly.Callback; import org.apache.tuscany.sca.assembly.ComponentType; import org.apache.tuscany.sca.assembly.Contract; import org.apache.tuscany.sca.assembly.Extensible; +import org.apache.tuscany.sca.assembly.ExtensionFactory; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; @@ -65,9 +66,11 @@ public class ComponentTypeProcessor extends BaseAssemblyProcessor implements StA * @param policyFactory * @param registry */ - public ComponentTypeProcessor(AssemblyFactory factory, PolicyFactory policyFactory, + public ComponentTypeProcessor(AssemblyFactory factory, + ExtensionFactory extensionFactory, + PolicyFactory policyFactory, StAXArtifactProcessor extensionProcessor, StAXAttributeProcessor extensionAttributeProcessor, Monitor monitor) { - super(factory, policyFactory, extensionProcessor, monitor); + super(factory, extensionFactory, policyFactory, extensionProcessor, monitor); } /** @@ -81,7 +84,10 @@ public class ComponentTypeProcessor extends BaseAssemblyProcessor implements StA StAXAttributeProcessor extensionAttributeProcessor, Monitor monitor) { super(modelFactories.getFactory(AssemblyFactory.class), - modelFactories.getFactory(PolicyFactory.class), extensionProcessor, monitor); + modelFactories.getFactory(ExtensionFactory.class), + modelFactories.getFactory(PolicyFactory.class), + extensionProcessor, + monitor); } public ComponentType read(XMLStreamReader reader) throws ContributionReadException { diff --git a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java index a2e67dc6c5..98564062d6 100644 --- a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java +++ b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java @@ -67,7 +67,7 @@ public class CompositeDocumentProcessor extends BaseAssemblyProcessor implements */ public CompositeDocumentProcessor(StAXArtifactProcessor staxProcessor, XMLInputFactory inputFactory, List scaDefnsSink, Monitor monitor) { - super(null, null, staxProcessor, monitor); + super(null, null, null, staxProcessor, monitor); this.inputFactory = inputFactory; this.scaDefnSink = scaDefnsSink; } @@ -79,7 +79,7 @@ public class CompositeDocumentProcessor extends BaseAssemblyProcessor implements */ public CompositeDocumentProcessor(ModelFactoryExtensionPoint modelFactories, StAXArtifactProcessor staxProcessor, Monitor monitor) { - super(null, null, staxProcessor, monitor); + super(null, null, null, staxProcessor, monitor); this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class); } diff --git a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java index 5aae007739..fa45585640 100644 --- a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java +++ b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java @@ -49,6 +49,7 @@ import org.apache.tuscany.sca.assembly.CompositeService; 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.ExtensionFactory; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.OperationsConfigurator; import org.apache.tuscany.sca.assembly.Property; @@ -124,6 +125,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt super(modelFactories.getFactory(ContributionFactory.class), modelFactories.getFactory(AssemblyFactory.class), + modelFactories.getFactory(ExtensionFactory.class), modelFactories.getFactory(PolicyFactory.class), extensionProcessor, monitor); @@ -142,11 +144,12 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt */ public CompositeProcessor(ContributionFactory contributionFactory, AssemblyFactory assemblyFactory, + ExtensionFactory extensionFactory, PolicyFactory policyFactory, StAXArtifactProcessor extensionProcessor, StAXAttributeProcessor extensionAttributeProcessor, Monitor monitor) { - super(contributionFactory, assemblyFactory, policyFactory, extensionProcessor, monitor); + super(contributionFactory, assemblyFactory, extensionFactory, policyFactory, extensionProcessor, monitor); } public Composite read(XMLStreamReader reader) throws ContributionReadException { diff --git a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java index 4c5d6f8f49..546679ddc1 100644 --- a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java +++ b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java @@ -56,7 +56,7 @@ public class ConstrainingTypeDocumentProcessor extends BaseAssemblyProcessor imp public ConstrainingTypeDocumentProcessor(StAXArtifactProcessor staxProcessor, XMLInputFactory inputFactory, Monitor monitor) { - super(null, null, staxProcessor, monitor); + super(null, null, null, staxProcessor, monitor); this.inputFactory = inputFactory; } @@ -68,7 +68,7 @@ public class ConstrainingTypeDocumentProcessor extends BaseAssemblyProcessor imp public ConstrainingTypeDocumentProcessor(ModelFactoryExtensionPoint modelFactories, StAXArtifactProcessor staxProcessor, Monitor monitor) { - super(null, null, staxProcessor, monitor); + super(null, null, null, staxProcessor, monitor); this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class); } diff --git a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java index 7b0751437a..21742a7d9c 100644 --- a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java +++ b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java @@ -33,6 +33,7 @@ import org.apache.tuscany.sca.assembly.AbstractReference; import org.apache.tuscany.sca.assembly.AbstractService; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.ExtensionFactory; import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; @@ -55,13 +56,16 @@ public class ConstrainingTypeProcessor extends BaseAssemblyProcessor implements /** * Construct a new constrainingType processor. - * @param factory + * @param assemblyFactory * @param policyFactory * @param extensionProcessor */ - public ConstrainingTypeProcessor(AssemblyFactory factory, PolicyFactory policyFactory, - StAXArtifactProcessor extensionProcessor, Monitor monitor) { - super(factory, policyFactory, extensionProcessor, monitor); + public ConstrainingTypeProcessor(AssemblyFactory assemblyFactory, + ExtensionFactory extensionFactory, + PolicyFactory policyFactory, + StAXArtifactProcessor extensionProcessor, + Monitor monitor) { + super(assemblyFactory, extensionFactory, policyFactory, extensionProcessor, monitor); } /** @@ -74,7 +78,10 @@ public class ConstrainingTypeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor extensionProcessor, Monitor monitor) { super(modelFactories.getFactory(AssemblyFactory.class), - modelFactories.getFactory(PolicyFactory.class), extensionProcessor, monitor); + modelFactories.getFactory(ExtensionFactory.class), + modelFactories.getFactory(PolicyFactory.class), + extensionProcessor, + monitor); } public ConstrainingType read(XMLStreamReader reader) throws ContributionReadException { diff --git a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java index a63ccdf151..34878a9f53 100644 --- a/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java +++ b/branches/sca-java-1.3.3/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java @@ -35,13 +35,14 @@ import javax.xml.stream.XMLStreamWriter; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Base; import org.apache.tuscany.sca.assembly.ComponentType; +import org.apache.tuscany.sca.assembly.ExtensionFactory; import org.apache.tuscany.sca.assembly.Implementation; -import org.apache.tuscany.sca.monitor.Monitor; 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.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.policy.PolicyFactory; import org.apache.tuscany.sca.policy.PolicySetAttachPoint; @@ -60,12 +61,13 @@ public class DefaultBeanModelProcessor extends BaseAssemblyProcessor implements private Map<String, Method> getterMethods = new HashMap<String, Method>(); public DefaultBeanModelProcessor(AssemblyFactory assemblyFactory, - PolicyFactory policyFactory, - QName artifactType, - Class<Implementation> modelClass, - Object modelFactory, - Monitor monitor) { - super(assemblyFactory, policyFactory, null, monitor); + ExtensionFactory extensionFactory, + PolicyFactory policyFactory, + QName artifactType, + Class<Implementation> modelClass, + Object modelFactory, + Monitor monitor) { + super(assemblyFactory, extensionFactory, policyFactory, null, monitor); this.artifactType = artifactType; this.modelClass = modelClass; this.modelFactory = modelFactory; |