diff options
author | rsivaram <rsivaram@13f79535-47bb-0310-9956-ffa450edef68> | 2008-10-21 09:04:28 +0000 |
---|---|---|
committer | rsivaram <rsivaram@13f79535-47bb-0310-9956-ffa450edef68> | 2008-10-21 09:04:28 +0000 |
commit | e753f271ccf0ff4617725130b82dd21ae721b3d2 (patch) | |
tree | 41c5d085b635978d93a1ba068980dc459ca157bc /sandbox/event/modules/assembly-xml | |
parent | a7ad2f6b64171d59288ebd468363255a29d464a0 (diff) |
Event prototype: Initial model changes
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@706556 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
2 files changed, 126 insertions, 0 deletions
diff --git a/sandbox/event/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/sandbox/event/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java index 09ec7664ce..93199e7d6f 100644 --- a/sandbox/event/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java +++ b/sandbox/event/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java @@ -40,10 +40,14 @@ import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.Callback; import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentConsumer; +import org.apache.tuscany.sca.assembly.ComponentProducer; import org.apache.tuscany.sca.assembly.ComponentProperty; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.CompositeConsumer; +import org.apache.tuscany.sca.assembly.CompositeProducer; import org.apache.tuscany.sca.assembly.CompositeReference; import org.apache.tuscany.sca.assembly.CompositeService; import org.apache.tuscany.sca.assembly.ConfiguredOperation; @@ -159,6 +163,10 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt ComponentProperty componentProperty = null; CompositeService compositeService = null; CompositeReference compositeReference = null; + ComponentConsumer componentConsumer = null; + ComponentProducer componentProducer = null; + CompositeConsumer compositeConsumer = null; + CompositeProducer compositeProducer = null; Contract contract = null; Wire wire = null; Callback callback = null; @@ -297,6 +305,108 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt composite.getReferences().add(compositeReference); policyProcessor.readPolicies(contract, reader); } + } else if (CONSUMER_QNAME.equals(name)) { + if (component != null) { + + // Read a <component><consumer> + componentConsumer = assemblyFactory.createComponentConsumer(); + contract = componentConsumer; + componentConsumer.setName(getString(reader, NAME)); + + //handle extension attributes + this.readExtendedAttributes(reader, name, componentConsumer, extensionAttributeProcessor); + + component.getConsumers().add(componentConsumer); + policyProcessor.readPolicies(componentConsumer, reader); + + } else { + + // Read a <composite><consumer> + compositeConsumer = assemblyFactory.createCompositeConsumer(); + contract = componentConsumer; + compositeConsumer.setName(getString(reader, NAME)); + + String promoted = getString(reader, PROMOTE); + if (promoted != null) { + String promotedComponentName; + String promotedConsumerName; + int s = promoted.indexOf('/'); + if (s == -1) { + promotedComponentName = promoted; + promotedConsumerName = null; + } else { + promotedComponentName = promoted.substring(0, s); + promotedConsumerName = promoted.substring(s + 1); + } + + Component promotedComponent = assemblyFactory.createComponent(); + promotedComponent.setUnresolved(true); + promotedComponent.setName(promotedComponentName); + compositeConsumer.setPromotedComponent(promotedComponent); + + ComponentConsumer promotedConsumer = assemblyFactory.createComponentConsumer(); + promotedConsumer.setUnresolved(true); + promotedConsumer.setName(promotedConsumerName); + compositeConsumer.setPromotedConsumer(promotedConsumer); + } + + //handle extension attributes + this.readExtendedAttributes(reader, name, compositeConsumer, extensionAttributeProcessor); + + composite.getConsumers().add(compositeConsumer); + policyProcessor.readPolicies(compositeConsumer, reader); + } + + } else if (PRODUCER_QNAME.equals(name)) { + if (component != null) { + // Read a <component><reference> + componentProducer = assemblyFactory.createComponentProducer(); + contract = componentProducer; + componentProducer.setName(getString(reader, NAME)); + + //handle extension attributes + this.readExtendedAttributes(reader, name, componentProducer, extensionAttributeProcessor); + + component.getProducers().add(componentProducer); + policyProcessor.readPolicies(componentProducer, reader); + + } else { + // Read a <composite><reference> + compositeProducer = assemblyFactory.createCompositeProducer(); + contract = componentProducer; + compositeProducer.setName(getString(reader, NAME)); + String promoted = getString(reader, PROMOTE); + if (promoted != null) { + String promotedComponentName; + String promotedProducerName; + int s = promoted.indexOf('/'); + if (s == -1) { + promotedComponentName = promoted; + promotedProducerName = null; + } else { + promotedComponentName = promoted.substring(0, s); + promotedProducerName = promoted.substring(s + 1); + } + + Component promotedComponent = assemblyFactory.createComponent(); + promotedComponent.setUnresolved(true); + promotedComponent.setName(promotedComponentName); + compositeProducer.setPromotedComponent(promotedComponent); + + ComponentProducer promotedProducer = assemblyFactory.createComponentProducer(); + promotedProducer.setUnresolved(true); + promotedProducer.setName(promotedProducerName); + compositeProducer.setPromotedProducer(promotedProducer); + } + + //handle extension attributes + this.readExtendedAttributes(reader, name, compositeProducer, extensionAttributeProcessor); + + composite.getProducers().add(compositeProducer); + policyProcessor.readPolicies(compositeProducer, reader); + } + + } else if (PROPERTY_QNAME.equals(name)) { if (component != null) { @@ -560,6 +670,12 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt wire = null; } else if (CALLBACK_QNAME.equals(name)) { callback = null; + } else if (CONSUMER_QNAME.equals(name)) { + componentConsumer = null; + compositeConsumer = null; + } else if (PRODUCER_QNAME.equals(name)) { + componentProducer = null; + compositeProducer = null; } break; } @@ -946,6 +1062,8 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt //Resolve composite services and references resolveContracts(composite, composite.getServices(), resolver); resolveContracts(composite, composite.getReferences(), resolver); + resolveContracts(composite, composite.getConsumers(), resolver); + resolveContracts(composite, composite.getProducers(), resolver); // Resolve component implementations, services and references for (Component component : composite.getComponents()) { @@ -971,6 +1089,8 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt //resolve component services and references resolveContracts(component, component.getServices(), resolver); resolveContracts(component, component.getReferences(), resolver); + resolveContracts(component, component.getConsumers(), resolver); + resolveContracts(component, component.getProducers(), resolver); for (ComponentProperty componentProperty : component.getProperties()) { if (componentProperty.getFile() != null) { diff --git a/sandbox/event/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java b/sandbox/event/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java index 3bf5a1173b..8f29f4efa4 100644 --- a/sandbox/event/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java +++ b/sandbox/event/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java @@ -72,6 +72,12 @@ public interface Constants { String BINDING_SCA = "binding.sca"; QName BINDING_SCA_QNAME = new QName(Constants.SCA10_NS, BINDING_SCA); + String CONSUMER = "consumer"; + QName CONSUMER_QNAME = new QName(SCA10_NS, CONSUMER); + + String PRODUCER = "producer"; + QName PRODUCER_QNAME = new QName(SCA10_NS, PRODUCER); + String NAME = "name"; String TARGET_NAMESPACE = "targetNamespace"; String LOCAL = "local"; |