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 | |
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')
8 files changed, 115 insertions, 72 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()); diff --git a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java b/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java index b07c91d1b3..ec355e069e 100644 --- a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java +++ b/branches/sca-java-1.x/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.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java b/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java index 07e1507449..f1608386ba 100644 --- a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java +++ b/branches/sca-java-1.x/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; @@ -61,13 +62,15 @@ public class ComponentTypeProcessor extends BaseAssemblyProcessor implements StA /** * Constructs a new componentType processor. - * @param factory + * @param assemblyFactory * @param policyFactory * @param registry */ - public ComponentTypeProcessor(AssemblyFactory factory, PolicyFactory policyFactory, + public ComponentTypeProcessor(AssemblyFactory assemblyFactory, + ExtensionFactory extensionFactory, + PolicyFactory policyFactory, StAXArtifactProcessor extensionProcessor, StAXAttributeProcessor extensionAttributeProcessor, Monitor monitor) { - super(factory, policyFactory, extensionProcessor, monitor); + super(assemblyFactory, 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.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java b/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java index bc74773d85..f630f22548 100644 --- a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java +++ b/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java @@ -63,43 +63,52 @@ public class CompositeDocumentProcessor extends BaseAssemblyProcessor implements /** * Construct a new composite processor - * @param assemblyFactory - * @param policyFactory * @param staxProcessor + * @param inputFactory + * @param scaDefnsSink + * @param monitor */ @Deprecated public CompositeDocumentProcessor(StAXArtifactProcessor staxProcessor, - XMLInputFactory inputFactory, - List scaDefnsSink, Monitor monitor) { - super(null, null, staxProcessor, monitor); + XMLInputFactory inputFactory, + List scaDefnsSink, + Monitor monitor) { + super(null, null, null, staxProcessor, monitor); this.inputFactory = inputFactory; this.scaDefnSink = scaDefnsSink; } + /** * Construct a new composite processor - * @param assemblyFactory - * @param policyFactory * @param staxProcessor + * @param inputFactory + * @param documentBuilderFactory + * @param scaDefnsSink + * @param monitor */ public CompositeDocumentProcessor(StAXArtifactProcessor staxProcessor, - XMLInputFactory inputFactory, - DocumentBuilderFactory documentBuilderFactory, - List scaDefnsSink, Monitor monitor) { - super(null, null, staxProcessor, monitor); + XMLInputFactory inputFactory, + DocumentBuilderFactory documentBuilderFactory, + List scaDefnsSink, + Monitor monitor) { + super(null, null, null, staxProcessor, monitor); this.documentBuilderFactory = documentBuilderFactory; this.inputFactory = inputFactory; this.scaDefnSink = scaDefnsSink; } + /** - * Constructs a new composite processor. + * Construct a new composite processor * @param modelFactories * @param staxProcessor + * @param monitor */ public CompositeDocumentProcessor(ModelFactoryExtensionPoint modelFactories, - StAXArtifactProcessor staxProcessor, Monitor monitor) { - super(null, null, staxProcessor, monitor); + StAXArtifactProcessor staxProcessor, + Monitor monitor) { + super(null, null, null, staxProcessor, monitor); this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class); this.documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); } diff --git a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java index 285bcc448d..4df51ff11b 100644 --- a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java +++ b/branches/sca-java-1.x/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; @@ -102,10 +103,10 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt StAXAttributeProcessor extensionAttributeProcessor, Monitor monitor) { - this(modelFactories(extensionPoints), - extensionProcessor, - extensionAttributeProcessor, - monitor(extensionPoints)); + this(modelFactories(extensionPoints), + extensionProcessor, + extensionAttributeProcessor, + monitor(extensionPoints)); this.extensionAttributeProcessor = extensionAttributeProcessor; } @@ -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.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java b/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java index 4c5d6f8f49..0e6d8be1db 100644 --- a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java +++ b/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeDocumentProcessor.java @@ -47,28 +47,32 @@ import org.apache.tuscany.sca.monitor.Monitor; public class ConstrainingTypeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor<ConstrainingType> { private XMLInputFactory inputFactory; + /** * Construct a new constrainingType processor. - * @param factory - * @param policyFactory + * * @param staxProcessor + * @param inputFactory + * @param monitor */ public ConstrainingTypeDocumentProcessor(StAXArtifactProcessor staxProcessor, - XMLInputFactory inputFactory, - Monitor monitor) { - super(null, null, staxProcessor, monitor); + XMLInputFactory inputFactory, + Monitor monitor) { + super(null, null, null, staxProcessor, monitor); this.inputFactory = inputFactory; } + /** * Constructs a new constrainingType processor. * @param modelFactories * @param staxProcessor + * @param monitor */ public ConstrainingTypeDocumentProcessor(ModelFactoryExtensionPoint modelFactories, - StAXArtifactProcessor staxProcessor, - Monitor monitor) { - super(null, null, staxProcessor, monitor); + StAXArtifactProcessor staxProcessor, + Monitor monitor) { + super(null, null, null, staxProcessor, monitor); this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class); } diff --git a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java b/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java index 7b0751437a..730c320265 100644 --- a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java +++ b/branches/sca-java-1.x/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); } /** @@ -71,10 +75,13 @@ public class ConstrainingTypeProcessor extends BaseAssemblyProcessor implements * @param extensionProcessor */ public ConstrainingTypeProcessor(ModelFactoryExtensionPoint modelFactories, - StAXArtifactProcessor extensionProcessor, - Monitor monitor) { + 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.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java b/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java index a63ccdf151..29c1b649ec 100644 --- a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java +++ b/branches/sca-java-1.x/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; |