diff options
Diffstat (limited to 'sandbox')
2 files changed, 51 insertions, 1 deletions
diff --git a/sandbox/event/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/sandbox/event/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java index 06b208540a..0fd745ce0e 100644 --- a/sandbox/event/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java +++ b/sandbox/event/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java @@ -43,9 +43,12 @@ import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Base; import org.apache.tuscany.sca.assembly.Binding; 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.ComponentService; import org.apache.tuscany.sca.assembly.ComponentType; import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.Consumer; import org.apache.tuscany.sca.assembly.ConfiguredOperation; import org.apache.tuscany.sca.assembly.ConstrainingType; import org.apache.tuscany.sca.assembly.Contract; @@ -53,6 +56,7 @@ import org.apache.tuscany.sca.assembly.Extensible; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Multiplicity; import org.apache.tuscany.sca.assembly.OperationsConfigurator; +import org.apache.tuscany.sca.assembly.Producer; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl; @@ -251,6 +255,44 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implement reference.setMultiplicity(Multiplicity.ZERO_N); } } + + /** + * Read list of producer targets + * @param producer - the producer + * @param reader - XMLStreamReader for the producer element + */ + protected void readProducerTargets(Producer producer, XMLStreamReader reader) { + String value = reader.getAttributeValue(null, TARGET); + ComponentConsumer target = null; + // TODO - need to deal with a target that is a Channel + if (value != null) { + for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { + target = assemblyFactory.createComponentConsumer(); + target.setUnresolved(true); + target.setName(tokens.nextToken()); + producer.getTargets().add(target); + } + } + } // end readProducerTargets + + /** + * Read list of consumer sources + * @param producer - the consumer + * @param reader - XMLStreamReader for the consumer element + */ + protected void readConsumerSources(Consumer consumer, XMLStreamReader reader) { + String value = reader.getAttributeValue(null, SOURCE); + ComponentProducer source = null; + // TODO - need to deal with a source that is a Channel + if (value != null) { + for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { + source = assemblyFactory.createComponentProducer(); + source.setUnresolved(true); + source.setName(tokens.nextToken()); + consumer.getSources().add(source); + } + } + } // end readConsumerSources /** * Returns the value of a constrainingType attribute. 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 be57b6cb9d..7a278ae806 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 @@ -321,6 +321,8 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } // end for } // end if + readConsumerSources( componentConsumer, reader ); + //handle extension attributes this.readExtendedAttributes(reader, name, componentConsumer, extensionAttributeProcessor); @@ -341,6 +343,8 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt compositeConsumer.getEventTypes().addEventType(tokens.nextToken()); } // end for } // end if + + //TODO deal with @source attribute String promoted = getString(reader, PROMOTE); if (promoted != null) { @@ -388,6 +392,8 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } // end for } // end if + readProducerTargets( componentProducer, reader ); + //handle extension attributes this.readExtendedAttributes(reader, name, componentProducer, extensionAttributeProcessor); @@ -395,7 +401,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt policyProcessor.readPolicies(componentProducer, reader); } else { - // Read a <composite><reference> + // Read a <composite><producer> compositeProducer = assemblyFactory.createCompositeProducer(); contract = componentProducer; compositeProducer.setName(getString(reader, NAME)); @@ -408,6 +414,8 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } // end for } // end if + //TODO deal with @target attribute + String promoted = getString(reader, PROMOTE); if (promoted != null) { String promotedComponentName; |