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 | |
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 'sandbox/event/modules')
39 files changed, 1395 insertions, 17 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"; diff --git a/sandbox/event/modules/assembly-xsd/src/main/resources/sca-core.xsd b/sandbox/event/modules/assembly-xsd/src/main/resources/sca-core.xsd index b0d94102af..6e4a63d09c 100644 --- a/sandbox/event/modules/assembly-xsd/src/main/resources/sca-core.xsd +++ b/sandbox/event/modules/assembly-xsd/src/main/resources/sca-core.xsd @@ -15,7 +15,9 @@ <choice minOccurs="0" maxOccurs="unbounded"> <element name="service" type="sca:ComponentService" /> <element name="reference" type="sca:ComponentReference"/> - <element name="property" type="sca:Property"/> + <element name="property" type="sca:Property"/> + <element name="producer" type="sca:ComponentProducer"/> + <element name="consumer" type="sca:ComponentConsumer"/> </choice> <!-- <any namespace="##other" processContents="lax" minOccurs="0" @@ -34,7 +36,9 @@ <element name="service" type="sca:Service"/> <element name="property" type="sca:Property"/> <element name="component" type="sca:Component"/> - <element name="reference" type="sca:Reference"/> + <element name="reference" type="sca:Reference"/> + <element name="producer" type="sca:Producer"/> + <element name="consumer" type="sca:Consumer"/> <element name="wire" type="sca:Wire"/> <!-- <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> --> </choice> @@ -147,6 +151,41 @@ </complexContent> </complexType> + + <complexType name="Producer"> + <sequence> + <element name="operation" type="sca:Operation" minOccurs="0" + maxOccurs="unbounded" /> + <choice minOccurs="0" maxOccurs="unbounded"> + <element ref="sca:binding" /> + <any namespace="##other" processContents="lax"/> + </choice> + </sequence> + <attribute name="name" type="NCName" use="required" /> + <attribute name="promote" type="anyURI" use="required" /> + <attribute name="target" type="sca:listOfAnyURIs" use="optional" /> + <attribute name="requires" type="sca:listOfQNames" use="optional" /> + <attribute name="policySets" type="sca:listOfQNames" use="optional"/> + <anyAttribute namespace="##any" processContents="lax" /> + </complexType> + + <complexType name="Consumer"> + <sequence> + <element name="operation" type="sca:Operation" minOccurs="0" + maxOccurs="unbounded" /> + <choice minOccurs="0" maxOccurs="unbounded"> + <element ref="sca:binding" /> + <any namespace="##other" processContents="lax"/> + </choice> + </sequence> + <attribute name="name" type="NCName" use="required" /> + <attribute name="promote" type="anyURI" use="required" /> + <attribute name="source" type="sca:listOfAnyURIs" use="optional" /> + <attribute name="requires" type="sca:listOfQNames" use="optional" /> + <attribute name="policySets" type="sca:listOfQNames" use="optional"/> + <anyAttribute namespace="##any" processContents="lax" /> + </complexType> + <element name="binding" type="sca:Binding" abstract="true"/> <complexType name="Binding" abstract="true"> <sequence> @@ -190,7 +229,9 @@ <choice minOccurs="0" maxOccurs="unbounded"> <element name="service" type="sca:ComponentService"/> <element name="reference" type="sca:ComponentReference"/> - <element name="property" type="sca:PropertyValue" /> + <element name="property" type="sca:PropertyValue" /> + <element name="producer" type="sca:ComponentProducer"/> + <element name="consumer" type="sca:ComponentConsumer"/> </choice> <!-- <any namespace="##other" processContents="lax" minOccurs="0" @@ -252,6 +293,43 @@ use="optional"/> <anyAttribute namespace="##any" processContents="lax" /> </complexType> + + <complexType name="ComponentProducer"> + <sequence> + <element name="operation" type="sca:Operation" minOccurs="0" + maxOccurs="unbounded" /> + <choice minOccurs="0" maxOccurs="unbounded"> + <element ref="sca:binding" /> + <any namespace="##other" processContents="lax"/> + </choice> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="target" type="sca:listOfAnyURIs" use="optional" /> + <attribute name="requires" type="sca:listOfQNames" + use="optional"/> + <attribute name="policySets" type="sca:listOfQNames" + use="optional"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <complexType name="ComponentConsumer"> + <sequence> + <element name="operation" type="sca:Operation" minOccurs="0" + maxOccurs="unbounded" /> + <choice minOccurs="0" maxOccurs="unbounded"> + <element ref="sca:binding" /> + <any namespace="##other" processContents="lax"/> + </choice> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="source" type="sca:listOfAnyURIs" use="optional" /> + <attribute name="requires" type="sca:listOfQNames" + use="optional"/> + <attribute name="policySets" type="sca:listOfQNames" + use="optional"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + <element name="implementation" type="sca:Implementation" abstract="true" /> diff --git a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java index 8a4fc6dfda..04fd754427 100644 --- a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java +++ b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java @@ -81,6 +81,20 @@ public interface AssemblyFactory { * @return a new component service */ ComponentService createComponentService(); + + /** + * Create a new component producer. + * + * @return a new component producer + */ + ComponentProducer createComponentProducer(); + + /** + * Create a new component consumer. + * + * @return a new component consumer + */ + ComponentConsumer createComponentConsumer(); /** * Create a new component type @@ -109,6 +123,21 @@ public interface AssemblyFactory { * @return a new composite service */ CompositeService createCompositeService(); + + + /** + * Create a new composite producer. + * + * @return a new composite producer + */ + CompositeProducer createCompositeProducer(); + + /** + * Create a new composite consumer. + * + * @return a new composite consumer + */ + CompositeConsumer createCompositeConsumer(); /** * Create a new constraining type. @@ -137,6 +166,21 @@ public interface AssemblyFactory { * @return a new service */ Service createService(); + + + /** + * Create a new producer. + * + * @return a new producer + */ + Producer createProducer(); + + /** + * Create a new consumer. + * + * @return a new consumer + */ + Consumer createConsumer(); /** * Create a new wire. diff --git a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java index 8e1943224c..b6bc55c7bd 100644 --- a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java +++ b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java @@ -85,6 +85,20 @@ public interface Component extends Base, Extensible, PolicySetAttachPoint, Clone * @return a list of services exposed by the component */ List<ComponentService> getServices(); + + /** + * Returns a list of producers used by the component. + * + * @return a list of producers used by the component + */ + List<ComponentProducer> getProducers(); + + /** + * Returns a list of consumers exposed by the component. + * + * @return a list of consumers exposed by the component + */ + List<ComponentConsumer> getConsumers(); /** * Returns a list of properties for the component. diff --git a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java index e1ea65ea39..5f8cba585d 100644 --- a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java +++ b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java @@ -53,6 +53,21 @@ public interface ComponentType extends Base { */ List<Reference> getReferences(); + + /** + * Returns a list of consumers that are offered. + * + * @return a list of consumers that are offered + */ + List<Consumer> getConsumers(); + + /** + * Returns the list of producer types that are used. + * + * @return the list of producer types that are used + */ + List<Producer> getProducers(); + /** * Returns the list of properties that can be set. * diff --git a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java index 6f856986ad..0a4bd1939e 100644 --- a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java +++ b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java @@ -36,8 +36,12 @@ 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.Consumer; import org.apache.tuscany.sca.assembly.Contract; +import org.apache.tuscany.sca.assembly.EventBinding; +import org.apache.tuscany.sca.assembly.EventBindingFactory; import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.assembly.Producer; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.SCABinding; @@ -67,6 +71,7 @@ public abstract class BaseConfigurationBuilderImpl { private AssemblyFactory assemblyFactory; private SCABindingFactory scaBindingFactory; + private EventBindingFactory eventBindingFactory; private Monitor monitor; private InterfaceContractMapper interfaceContractMapper; private SCADefinitions policyDefinitions; @@ -75,6 +80,7 @@ public abstract class BaseConfigurationBuilderImpl { protected BaseConfigurationBuilderImpl(AssemblyFactory assemblyFactory, SCABindingFactory scaBindingFactory, + EventBindingFactory eventBindingFactory, DocumentBuilderFactory documentBuilderFactory, TransformerFactory transformerFactory, InterfaceContractMapper interfaceContractMapper, @@ -82,6 +88,7 @@ public abstract class BaseConfigurationBuilderImpl { Monitor monitor) { this.assemblyFactory = assemblyFactory; this.scaBindingFactory = scaBindingFactory; + this.eventBindingFactory = eventBindingFactory; this.documentBuilderFactory = documentBuilderFactory; this.transformerFactory = transformerFactory; this.interfaceContractMapper = interfaceContractMapper; @@ -110,6 +117,8 @@ public abstract class BaseConfigurationBuilderImpl { */ private void configureComponents(Composite composite, String uri) { String parentURI = uri; + + configureProducersAndConsumers(composite); // Process nested composites recursively for (Component component : composite.getComponents()) { @@ -1334,4 +1343,81 @@ public abstract class BaseConfigurationBuilderImpl { return URI.create(baseURI.toString() + str).normalize(); } + private void configureProducersAndConsumers(Composite composite) { + + for (Component component : composite.getComponents()) { + Implementation impl = component.getImplementation(); + for (Producer producer : impl.getProducers()) { + Reference reference = assemblyFactory.createReference(); + reference.setName(producer.getName()); + reference.setInterfaceContract(producer.getInterfaceContract()); + if (producer.getInterfaceContract() != null && producer.getInterfaceContract().getInterface() != null) + producer.getInterfaceContract().getInterface().setRemotable(true); + reference.setType(producer.getType()); + reference.getApplicablePolicySets().addAll(producer.getApplicablePolicySets()); + reference.getPolicySets().addAll(producer.getPolicySets()); + reference.getRequiredIntents().addAll(producer.getRequiredIntents()); + for (Binding binding : producer.getBindings()) { + EventBinding eventBinding = eventBindingFactory.createEventBinding(); + eventBinding.setBaseBinding(binding); + reference.getBindings().add(binding);// FIXME: remove + reference.getBindings().add(eventBinding); + } + impl.getReferences().add(reference); + } + + for (Producer producer : component.getProducers()) { + ComponentReference reference = assemblyFactory.createComponentReference(); + reference.setName(producer.getName()); + reference.setInterfaceContract(producer.getInterfaceContract()); + if (producer.getInterfaceContract() != null && producer.getInterfaceContract().getInterface() != null) + producer.getInterfaceContract().getInterface().setRemotable(true); + reference.setType(producer.getType()); + reference.getApplicablePolicySets().addAll(producer.getApplicablePolicySets()); + reference.getPolicySets().addAll(producer.getPolicySets()); + reference.getRequiredIntents().addAll(producer.getRequiredIntents()); + for (Binding binding : producer.getBindings()) { + EventBinding eventBinding = eventBindingFactory.createEventBinding(); + eventBinding.setBaseBinding(binding); + reference.getBindings().add(binding);// FIXME: remove + reference.getBindings().add(eventBinding); + } + component.getReferences().add(reference); + } + + for (Consumer consumer : impl.getConsumers()) { + Service service = assemblyFactory.createService(); + service.setName(consumer.getName()); + service.setInterfaceContract(consumer.getInterfaceContract()); + service.setType(consumer.getType()); + service.getApplicablePolicySets().addAll(consumer.getApplicablePolicySets()); + service.getPolicySets().addAll(consumer.getPolicySets()); + service.getRequiredIntents().addAll(consumer.getRequiredIntents()); + for (Binding binding : consumer.getBindings()) { + EventBinding eventBinding = eventBindingFactory.createEventBinding(); + eventBinding.setBaseBinding(binding); + service.getBindings().add(binding);// FIXME: remove + service.getBindings().add(eventBinding); + } + impl.getServices().add(service); + } + + for (Consumer consumer : component.getConsumers()) { + ComponentService service = assemblyFactory.createComponentService(); + service.setName(consumer.getName()); + service.setInterfaceContract(consumer.getInterfaceContract()); + service.setType(consumer.getType()); + service.getApplicablePolicySets().addAll(consumer.getApplicablePolicySets()); + service.getPolicySets().addAll(consumer.getPolicySets()); + service.getRequiredIntents().addAll(consumer.getRequiredIntents()); + for (Binding binding : consumer.getBindings()) { + EventBinding eventBinding = eventBindingFactory.createEventBinding(); + eventBinding.setBaseBinding(binding); + service.getBindings().add(binding); // FIXME: remove + service.getBindings().add(eventBinding); + } + component.getServices().add(service); + } + } + } } diff --git a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java index 0643421a45..115051fa9a 100644 --- a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java +++ b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java @@ -24,6 +24,7 @@ import javax.xml.transform.TransformerFactory; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.EventBindingFactory; import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; @@ -45,10 +46,11 @@ public class ComponentConfigurationBuilderImpl extends BaseConfigurationBuilderI SCADefinitions policyDefinitions, Monitor monitor) { super(assemblyFactory, scaBindingFactory, - null, null, + null, null, null, interfaceContractMapper, policyDefinitions, monitor); } + @Deprecated public ComponentConfigurationBuilderImpl(AssemblyFactory assemblyFactory, SCABindingFactory scaBindingFactory, DocumentBuilderFactory documentBuilderFactory, @@ -56,10 +58,25 @@ public class ComponentConfigurationBuilderImpl extends BaseConfigurationBuilderI InterfaceContractMapper interfaceContractMapper, SCADefinitions policyDefinitions, Monitor monitor) { - super(assemblyFactory, scaBindingFactory, + super(assemblyFactory, scaBindingFactory, null, documentBuilderFactory, transformerFactory, interfaceContractMapper, policyDefinitions, monitor); } + + public ComponentConfigurationBuilderImpl(AssemblyFactory assemblyFactory, + SCABindingFactory scaBindingFactory, + EventBindingFactory eventBindingFactory, + DocumentBuilderFactory documentBuilderFactory, + TransformerFactory transformerFactory, + InterfaceContractMapper interfaceContractMapper, + SCADefinitions policyDefinitions, + Monitor monitor) { + + super(assemblyFactory, scaBindingFactory, eventBindingFactory, + documentBuilderFactory, transformerFactory, + interfaceContractMapper, policyDefinitions, monitor); + + } public void build(Composite composite) throws CompositeBuilderException { configureComponents(composite); diff --git a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java index 85af173c0d..3f9c6e28b8 100644 --- a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java +++ b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java @@ -24,6 +24,7 @@ import javax.xml.transform.TransformerFactory; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.EventBindingFactory; import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; @@ -45,10 +46,11 @@ public class CompositeBindingURIBuilderImpl extends BaseConfigurationBuilderImpl SCADefinitions policyDefinitions, Monitor monitor) { super(assemblyFactory, scaBindingFactory, - null, null, + null, null, null, interfaceContractMapper, policyDefinitions, monitor); } + @Deprecated public CompositeBindingURIBuilderImpl(AssemblyFactory assemblyFactory, SCABindingFactory scaBindingFactory, DocumentBuilderFactory documentBuilderFactory, @@ -56,10 +58,24 @@ public class CompositeBindingURIBuilderImpl extends BaseConfigurationBuilderImpl InterfaceContractMapper interfaceContractMapper, SCADefinitions policyDefinitions, Monitor monitor) { - super(assemblyFactory, scaBindingFactory, + super(assemblyFactory, scaBindingFactory, null, documentBuilderFactory, transformerFactory, interfaceContractMapper, policyDefinitions, monitor); } + + public CompositeBindingURIBuilderImpl(AssemblyFactory assemblyFactory, + SCABindingFactory scaBindingFactory, + EventBindingFactory eventBindingFactory, + DocumentBuilderFactory documentBuilderFactory, + TransformerFactory transformerFactory, + InterfaceContractMapper interfaceContractMapper, + SCADefinitions policyDefinitions, + Monitor monitor) { + + super(assemblyFactory, scaBindingFactory, eventBindingFactory, + documentBuilderFactory, transformerFactory, + interfaceContractMapper, policyDefinitions, monitor); + } public void build(Composite composite) throws CompositeBuilderException { configureBindingURIsAndNames(composite); diff --git a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java index 282fe032ba..2840985e0f 100644 --- a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java +++ b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java @@ -27,6 +27,7 @@ import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.DefaultEndpointFactory; import org.apache.tuscany.sca.assembly.EndpointFactory; +import org.apache.tuscany.sca.assembly.EventBindingFactory; import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; @@ -79,7 +80,7 @@ public class CompositeBuilderImpl implements CompositeBuilder { InterfaceContractMapper interfaceContractMapper, SCADefinitions policyDefinitions, Monitor monitor) { - this(assemblyFactory, endpointFactory, scaBindingFactory, intentAttachPointTypeFactory, + this(assemblyFactory, endpointFactory, scaBindingFactory, null, intentAttachPointTypeFactory, null, null, interfaceContractMapper, policyDefinitions, monitor); } @@ -100,7 +101,7 @@ public class CompositeBuilderImpl implements CompositeBuilder { IntentAttachPointTypeFactory intentAttachPointTypeFactory, InterfaceContractMapper interfaceContractMapper, Monitor monitor) { - this(assemblyFactory, null, scaBindingFactory, intentAttachPointTypeFactory, + this(assemblyFactory, null, scaBindingFactory, null, intentAttachPointTypeFactory, null, null, interfaceContractMapper, null, monitor); } @@ -117,12 +118,13 @@ public class CompositeBuilderImpl implements CompositeBuilder { */ public CompositeBuilderImpl(AssemblyFactory assemblyFactory, SCABindingFactory scaBindingFactory, + EventBindingFactory eventBindingFactory, IntentAttachPointTypeFactory intentAttachPointTypeFactory, DocumentBuilderFactory documentBuilderFactory, TransformerFactory transformerFactory, InterfaceContractMapper interfaceContractMapper, Monitor monitor) { - this(assemblyFactory, null, scaBindingFactory, intentAttachPointTypeFactory, + this(assemblyFactory, null, scaBindingFactory, eventBindingFactory, intentAttachPointTypeFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper, null, monitor); } @@ -140,6 +142,7 @@ public class CompositeBuilderImpl implements CompositeBuilder { public CompositeBuilderImpl(AssemblyFactory assemblyFactory, EndpointFactory endpointFactory, SCABindingFactory scaBindingFactory, + EventBindingFactory eventBindingFactory, IntentAttachPointTypeFactory intentAttachPointTypeFactory, DocumentBuilderFactory documentBuilderFactory, TransformerFactory transformerFactory, @@ -156,10 +159,10 @@ public class CompositeBuilderImpl implements CompositeBuilder { componentReferencePromotionWireBuilder = new ComponentReferencePromotionWireBuilderImpl(assemblyFactory, endpointFactory, monitor); compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory, monitor); compositeCloneBuilder = new CompositeCloneBuilderImpl(monitor); - componentConfigurationBuilder = new ComponentConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper, policyDefinitions, monitor); + componentConfigurationBuilder = new ComponentConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, eventBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper, policyDefinitions, monitor); compositeServiceConfigurationBuilder = new CompositeServiceConfigurationBuilderImpl(assemblyFactory); compositeReferenceConfigurationBuilder = new CompositeReferenceConfigurationBuilderImpl(assemblyFactory); - compositeBindingURIBuilder = new CompositeBindingURIBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper, policyDefinitions, monitor); + compositeBindingURIBuilder = new CompositeBindingURIBuilderImpl(assemblyFactory, scaBindingFactory, eventBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper, policyDefinitions, monitor); componentServicePromotionBuilder = new ComponentServicePromotionBuilderImpl(assemblyFactory); compositeServicePromotionBuilder = new CompositeServicePromotionBuilderImpl(assemblyFactory); compositePromotionBuilder = new CompositePromotionBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper, monitor); diff --git a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java index 016a9a5b05..e3d9355930 100644 --- a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java +++ b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java @@ -25,15 +25,21 @@ import org.apache.tuscany.sca.assembly.AbstractService; import org.apache.tuscany.sca.assembly.AssemblyFactory; 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.ComponentType; 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; import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Consumer; +import org.apache.tuscany.sca.assembly.Producer; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; @@ -77,6 +83,15 @@ public abstract class AssemblyFactoryImpl implements AssemblyFactory { public ComponentService createComponentService() { return new ComponentServiceImpl(); } + + + public ComponentProducer createComponentProducer() { + return new ComponentProducerImpl(); + } + + public ComponentConsumer createComponentConsumer() { + return new ComponentConsumerImpl(); + } public ComponentType createComponentType() { return new ComponentTypeImpl(); @@ -93,6 +108,15 @@ public abstract class AssemblyFactoryImpl implements AssemblyFactory { public CompositeService createCompositeService() { return new CompositeServiceImpl(); } + + + public CompositeProducer createCompositeProducer() { + return new CompositeProducerImpl(); + } + + public CompositeConsumer createCompositeConsumer() { + return new CompositeConsumerImpl(); + } public ConstrainingType createConstrainingType() { return new ConstrainingTypeImpl(); @@ -109,6 +133,14 @@ public abstract class AssemblyFactoryImpl implements AssemblyFactory { public Service createService() { return new ServiceImpl(); } + + public Producer createProducer() { + return new ProducerImpl(); + } + + public Consumer createConsumer() { + return new ConsumerImpl(); + } public Wire createWire() { return new WireImpl(); diff --git a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java index 34429a6703..59a4237b9f 100644 --- a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java +++ b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java @@ -22,6 +22,8 @@ import java.util.ArrayList; import java.util.List; 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; @@ -46,6 +48,8 @@ public class ComponentImpl extends ExtensibleImpl implements Component, Cloneabl private List<ComponentProperty> properties = new ArrayList<ComponentProperty>(); private List<ComponentReference> references = new ArrayList<ComponentReference>(); private List<ComponentService> services = new ArrayList<ComponentService>(); + private List<ComponentProducer> producers = new ArrayList<ComponentProducer>(); + private List<ComponentConsumer> consumers = new ArrayList<ComponentConsumer>(); private List<Intent> requiredIntents = new ArrayList<Intent>(); private List<PolicySet> policySets = new ArrayList<PolicySet>(); private Boolean autowire; @@ -109,6 +113,14 @@ public class ComponentImpl extends ExtensibleImpl implements Component, Cloneabl return services; } + public List<ComponentProducer> getProducers() { + return producers; + } + + public List<ComponentConsumer> getConsumers() { + return consumers; + } + public void setConstrainingType(ConstrainingType constrainingType) { this.constrainingType = constrainingType; } diff --git a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java index bbe665d52f..189e13ecba 100644 --- a/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java +++ b/sandbox/event/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java @@ -23,6 +23,8 @@ import java.util.List; import org.apache.tuscany.sca.assembly.ComponentType; import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Consumer; +import org.apache.tuscany.sca.assembly.Producer; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; @@ -38,6 +40,9 @@ public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType, private List<Property> properties = new ArrayList<Property>(); private List<Reference> references = new ArrayList<Reference>(); private List<Service> services = new ArrayList<Service>(); + private List<Producer> producers = new ArrayList<Producer>(); + private List<Consumer> consumers = new ArrayList<Consumer>(); + /** * Constructs a new component type. */ @@ -86,6 +91,15 @@ public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType, public List<Service> getServices() { return services; } + + + public List<Producer> getProducers() { + return producers; + } + + public List<Consumer> getConsumers() { + return consumers; + } public void setConstrainingType(ConstrainingType constrainingType) { this.constrainingType = constrainingType; diff --git a/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/EventBindingDefinitionsProvider.java b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/EventBindingDefinitionsProvider.java new file mode 100644 index 0000000000..4ffb4d22d9 --- /dev/null +++ b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/EventBindingDefinitionsProvider.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.event; + +import java.net.URI; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; + +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.definitions.SCADefinitions; +import org.apache.tuscany.sca.provider.SCADefinitionsProvider; +import org.apache.tuscany.sca.provider.SCADefinitionsProviderException; + +/** + * Provider for Policy Intents and PolicySet definitions for event binding + * + * @version $$ + */ +public class EventBindingDefinitionsProvider implements SCADefinitionsProvider { + private String definitionsFile = "org/apache/tuscany/sca/binding/sca/definitions.xml"; + URLArtifactProcessor urlArtifactProcessor = null; + + public EventBindingDefinitionsProvider(ExtensionPointRegistry registry) { + URLArtifactProcessorExtensionPoint documentProcessors = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); + urlArtifactProcessor = (URLArtifactProcessor)documentProcessors.getProcessor(SCADefinitions.class); + } + + public SCADefinitions getSCADefinition() throws SCADefinitionsProviderException { + // Allow privileged access to load resource. Requires RuntimePermssion in security policy. + final URL definitionsFileUrl = AccessController.doPrivileged(new PrivilegedAction<URL>() { + public URL run() { + return getClass().getClassLoader().getResource(definitionsFile); + } + }); + + SCADefinitions scaDefn = null; + try { + final URI uri = new URI(definitionsFile); + // Allow bindings to read properties. Requires PropertyPermission read in security policy. + scaDefn = AccessController.doPrivileged(new PrivilegedExceptionAction<SCADefinitions>() { + public SCADefinitions run() throws ContributionReadException { + return (SCADefinitions)urlArtifactProcessor.read(null, uri, definitionsFileUrl); + } + }); + } catch (Exception e) { + throw new SCADefinitionsProviderException(e); + } + return scaDefn; + } + +} diff --git a/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingFactoryImpl.java b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingFactoryImpl.java new file mode 100644 index 0000000000..1b6300aab4 --- /dev/null +++ b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingFactoryImpl.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.event.impl; + +import org.apache.tuscany.sca.assembly.EventBinding; +import org.apache.tuscany.sca.assembly.EventBindingFactory; + +/** + * A factory for the Event binding model. + * + * @version $$ + */ +public class EventBindingFactoryImpl implements EventBindingFactory { + + public EventBindingFactoryImpl (){ + + } + + public EventBinding createEventBinding() { + return new EventBindingImpl(); + } + +} diff --git a/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingImpl.java b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingImpl.java new file mode 100644 index 0000000000..b07651960f --- /dev/null +++ b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingImpl.java @@ -0,0 +1,243 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.event.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.EventBinding; +import org.apache.tuscany.sca.assembly.Extensible; +import org.apache.tuscany.sca.assembly.OptimizableBinding; +import org.apache.tuscany.sca.assembly.builder.AutomaticBinding; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.IntentAttachPointType; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; + +/** + * The assembly mode object for an Event binding. + * + * @version $$ + */ +public class EventBindingImpl implements EventBinding, Extensible, PolicySetAttachPoint, OptimizableBinding, AutomaticBinding { + private String name; + private String uri; + private Binding baseBinding; + private List<Object> extensions = new ArrayList<Object>(); + private List<Intent> requiredIntents = new ArrayList<Intent>(); + private List<PolicySet> policySets = new ArrayList<PolicySet>(); + private IntentAttachPointType intentAttachPointType; + + private Component targetComponent; + private ComponentService targetComponentService; + private Binding targetBinding; + private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>(); + + private boolean isAutomatic = false; + + public List<PolicySet> getApplicablePolicySets() { + return applicablePolicySets; + } + + /** + * Constructs a new SCA binding. + */ + protected EventBindingImpl() { + } + + // Event Binding operations + + /** + * Setters for the binding name. Defaults to the + * name of the service or reference with which the binding is + * associated + * + * @return the binding name + */ + public String getName() { + return name; + } + + /** + * Setter for the binding name + * + * @param name the binding name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Getters for the binding URI. The computed URI for the + * service that the reference is targeting or which the service represents + * depending on whether the biding is associated with a reference or + * service + * + * @return the binding URI + */ + public String getURI() { + return uri; + } + + /** + * Setter for the binding URI + * + * @param uri the binding URI + */ + public void setURI(String uri) { + this.uri = uri; + } + + + /** + * Getter for the base binding + * + * @return base binding + */ + public Binding getBaseBinding() { + return baseBinding; + } + + /** + * Setter for the base binding + * + * @param baseBinding the base binding + */ + public void setBaseBinding(Binding baseBinding) { + this.baseBinding = baseBinding; + } + + /** + * Returns a list of extension objects contained in this model object. + * + * @return a list of extension objects container in this model object + */ + public List<Object> getExtensions() { + return extensions; + } + + /** + * Returns true if the model element is unresolved. + * + * @return true if the model element is unresolved. + */ + public boolean isUnresolved() { + if (targetComponentService == null){ + return true; + } else { + return targetComponentService.isUnresolved(); + } + } + + /** + * Sets whether the model element is unresolved. + * + * @param unresolved whether the model element is unresolved + */ + public void setUnresolved(boolean unresolved) { + } + + /** + * @see java.lang.Object#clone() + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public List<PolicySet> getPolicySets() { + return policySets; + } + + public List<Intent> getRequiredIntents() { + return requiredIntents; + } + + public IntentAttachPointType getType() { + return intentAttachPointType; + } + + public void setType(IntentAttachPointType intentAttachPointType) { + this.intentAttachPointType = intentAttachPointType; + } + + // Wireable binding operations + + /** + * @return the targetComponent + */ + public Component getTargetComponent() { + return targetComponent; + } + + /** + * @param targetComponent the targetComponent to set + */ + public void setTargetComponent(Component targetComponent) { + this.targetComponent = targetComponent; + } + + /** + * @return the targetComponentService + */ + public ComponentService getTargetComponentService() { + return targetComponentService; + } + + /** + * @param targetComponentService the targetComponentService to set + */ + public void setTargetComponentService(ComponentService targetComponentService) { + this.targetComponentService = targetComponentService; + } + + /** + * @return the targetBinding + */ + public Binding getTargetBinding() { + return targetBinding; + } + + /** + * @param targetBinding the targetBinding to set + */ + public void setTargetBinding(Binding targetBinding) { + this.targetBinding = targetBinding; + } + + public void setPolicySets(List<PolicySet> policySets) { + this.policySets = policySets; + } + + public void setRequiredIntents(List<Intent> intents) { + this.requiredIntents = intents; + } + + + public void setIsAutomatic(boolean isAutomatic){ + this.isAutomatic = isAutomatic; + } + + public boolean getIsAutomatic(){ + return this.isAutomatic; + } +} diff --git a/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingInvoker.java b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingInvoker.java new file mode 100644 index 0000000000..481f3b2b0a --- /dev/null +++ b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingInvoker.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.event.impl; + +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.InvocationChain; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.DataExchangeSemantics; + +/** + * TODO: Implement event binding invoker + * @version $$ + */ +public class EventBindingInvoker implements Interceptor, DataExchangeSemantics { + private InvocationChain chain; + + /** + * Construct a EventBindingInvoker that delegates to the service invocaiton chain + * @param chain + */ + public EventBindingInvoker(InvocationChain chain) { + super(); + this.chain = chain; + } + + /** + * @see org.apache.tuscany.sca.invocation.Interceptor#getNext() + */ + public Invoker getNext() { + return chain.getHeadInvoker(); + } + + /** + * @see org.apache.tuscany.sca.invocation.Interceptor#setNext(org.apache.tuscany.sca.invocation.Invoker) + */ + public void setNext(Invoker next) { + // NOOP + } + + /** + * @see org.apache.tuscany.sca.invocation.Invoker#invoke(org.apache.tuscany.sca.invocation.Message) + */ + public Message invoke(Message msg) { + return getNext().invoke(msg); + } + + /** + * @see org.apache.tuscany.sca.invocation.DataExchangeSemantics#allowsPassByReference() + */ + public boolean allowsPassByReference() { + return chain.allowsPassByReference(); + } + +} diff --git a/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingProvider.java b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingProvider.java new file mode 100644 index 0000000000..bb176eaaff --- /dev/null +++ b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingProvider.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.event.impl; + +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; + +/** + * The Event Binding provider implementation. + * + * @version $$ + */ +public class EventBindingProvider implements ReferenceBindingProvider { + + private RuntimeComponentReference reference; + + public EventBindingProvider(RuntimeComponent component, RuntimeComponentReference reference, EventBindingImpl binding) { + this.reference = reference; + } + + public InterfaceContract getBindingInterfaceContract() { + return reference.getInterfaceContract(); + } + + public Invoker createInvoker(Operation operation) { + return null; + } + + public void start() { + } + + public void stop() { + } + + public boolean supportsOneWayInvocation() { + return true; + } + +} diff --git a/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingProviderFactory.java b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingProviderFactory.java new file mode 100644 index 0000000000..7fc12c84b7 --- /dev/null +++ b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingProviderFactory.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.event.impl; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.provider.BindingProviderFactory; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * The factory for creating Event Binding providers + * + * @version $$ + */ +public class EventBindingProviderFactory implements BindingProviderFactory<EventBindingImpl> { + + private ExtensionPointRegistry extensionPoints; + + public EventBindingProviderFactory(ExtensionPointRegistry extensionPoints) { + this.extensionPoints = extensionPoints; + + } + + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, + RuntimeComponentReference reference, + EventBindingImpl binding) { + + return new EventReferenceBindingProvider(extensionPoints, component, reference, binding); + } + + public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, + RuntimeComponentService service, + EventBindingImpl binding) { + return new EventServiceBindingProvider(extensionPoints, component, service, binding); + } + + public Class<EventBindingImpl> getModelType() { + return EventBindingImpl.class; + } +} diff --git a/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventReferenceBindingProvider.java b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventReferenceBindingProvider.java new file mode 100644 index 0000000000..bb09fb5b77 --- /dev/null +++ b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventReferenceBindingProvider.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.event.impl; + +import java.util.logging.Logger; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; + +/** + * Event reference binding provider + * + * @version $$ + */ +public class EventReferenceBindingProvider implements ReferenceBindingProvider { + + @SuppressWarnings("unused") + private static final Logger logger = Logger.getLogger(EventReferenceBindingProvider.class.getName()); + + @SuppressWarnings("unused") + private RuntimeComponent component; + @SuppressWarnings("unused") + private EventBindingImpl binding; + private RuntimeComponentReference reference; + private boolean started = false; + private ReferenceBindingProvider baseBindingProvider; + + + public EventReferenceBindingProvider(ExtensionPointRegistry extensionPoints, + RuntimeComponent component, + RuntimeComponentReference reference, + EventBindingImpl binding) { + this.component = component; + this.reference = reference; + this.binding = binding; + + // TODO: Set baseBindingProvider + } + + + public InterfaceContract getBindingInterfaceContract() { + if (reference.getReference() != null) { + return reference.getReference().getInterfaceContract(); + } else { + return reference.getInterfaceContract(); + } + } + + public boolean supportsOneWayInvocation() { + return true; + } + + + public Invoker createInvoker(Operation operation) { + return baseBindingProvider.createInvoker(operation); + } + + public void start() { + if (started) { + return; + } else { + started = true; + } + } + + public void stop() { + if (!started) { + return; + } else { + started = false; + } + + } + +} diff --git a/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventServiceBindingProvider.java b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventServiceBindingProvider.java new file mode 100644 index 0000000000..593795aae0 --- /dev/null +++ b/sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventServiceBindingProvider.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.event.impl; + + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * The event service binding provider + * + * @version $$ + */ +public class EventServiceBindingProvider implements ServiceBindingProvider { + + private RuntimeComponentService service; + + public EventServiceBindingProvider(ExtensionPointRegistry extensionPoints, + RuntimeComponent component, + RuntimeComponentService service, + EventBindingImpl binding) { + this.service = service; + } + + public InterfaceContract getBindingInterfaceContract() { + if (service.getService() != null) { + return service.getService().getInterfaceContract(); + } else { + return service.getInterfaceContract(); + } + } + + public boolean supportsOneWayInvocation() { + return true; + } + + public void start() { + } + + public void stop() { + } + +} diff --git a/sandbox/event/modules/binding-event/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EventBindingFactory b/sandbox/event/modules/binding-event/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EventBindingFactory new file mode 100644 index 0000000000..b1a0b12c1d --- /dev/null +++ b/sandbox/event/modules/binding-event/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EventBindingFactory @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.apache.tuscany.sca.binding.event.impl.EventBindingFactoryImpl
diff --git a/sandbox/event/modules/binding-event/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sandbox/event/modules/binding-event/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..6102e4210e --- /dev/null +++ b/sandbox/event/modules/binding-event/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.event.impl.EventBindingProviderFactory;model=org.apache.tuscany.sca.binding.event.impl.EventBindingImpl
diff --git a/sandbox/event/modules/binding-event/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider b/sandbox/event/modules/binding-event/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider new file mode 100644 index 0000000000..9a923d1828 --- /dev/null +++ b/sandbox/event/modules/binding-event/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for SCA Definitions Providers +org.apache.tuscany.sca.binding.event.EventBindingDefinitionsProvider
\ No newline at end of file diff --git a/sandbox/event/modules/binding-event/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml b/sandbox/event/modules/binding-event/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml new file mode 100644 index 0000000000..559994b9f9 --- /dev/null +++ b/sandbox/event/modules/binding-event/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ASCII"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" + targetNamespace="http://www.osoa.org/xmlns/sca/1.0" + xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"> + + <sca:bindingType type="sca:binding.event" mayProvide="" alwaysProvides=""/> + </sca:definitions>
\ No newline at end of file diff --git a/sandbox/event/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/utils/AbstractImplementation.java b/sandbox/event/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/utils/AbstractImplementation.java index 0e658cfd1e..e78626c7da 100644 --- a/sandbox/event/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/utils/AbstractImplementation.java +++ b/sandbox/event/modules/extension-helper/src/main/java/org/apache/tuscany/sca/extension/helper/utils/AbstractImplementation.java @@ -24,7 +24,9 @@ import java.util.List; import org.apache.tuscany.sca.assembly.ConfiguredOperation; import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Consumer; import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.assembly.Producer; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; @@ -42,6 +44,8 @@ public abstract class AbstractImplementation implements Implementation { private List<Service> services = new ArrayList<Service>(); private List<Reference> references = new ArrayList<Reference>(); + private List<Producer> producers = new ArrayList<Producer>(); + private List<Consumer> consumers = new ArrayList<Consumer>(); private List<Property> properties = new ArrayList<Property>(); private ConstrainingType constrainingType; private String uri; @@ -66,6 +70,16 @@ public abstract class AbstractImplementation implements Implementation { public List<Service> getServices() { return services; } + + + public List<Producer> getProducers() { + return producers; + } + + public List<Consumer> getConsumers() { + return consumers; + } + public String getURI() { return uri; diff --git a/sandbox/event/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java b/sandbox/event/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java index 55b6afb6f2..82071b0821 100644 --- a/sandbox/event/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java +++ b/sandbox/event/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java @@ -33,6 +33,7 @@ import javax.xml.transform.TransformerFactory; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.EndpointFactory; +import org.apache.tuscany.sca.assembly.EventBindingFactory; import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; @@ -216,6 +217,7 @@ public class ReallySmallRuntime { //Get factory extension point ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class); SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class); + EventBindingFactory eventBindingFactory = factories.getFactory(EventBindingFactory.class); IntentAttachPointTypeFactory intentAttachPointTypeFactory = factories.getFactory(IntentAttachPointTypeFactory.class); EndpointFactory endpointFactory = factories.getFactory(EndpointFactory.class); UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); @@ -231,6 +233,7 @@ public class ReallySmallRuntime { compositeBuilder = ReallySmallRuntimeBuilder.createCompositeBuilder(monitor, assemblyFactory, scaBindingFactory, + eventBindingFactory, endpointFactory, intentAttachPointTypeFactory, documentBuilderFactory, diff --git a/sandbox/event/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java b/sandbox/event/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java index 738e5e6248..68f540d7f9 100644 --- a/sandbox/event/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java +++ b/sandbox/event/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntimeBuilder.java @@ -32,6 +32,7 @@ import javax.xml.transform.TransformerFactory; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.EndpointFactory; +import org.apache.tuscany.sca.assembly.EventBindingFactory; import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; @@ -142,6 +143,7 @@ public class ReallySmallRuntimeBuilder { public static CompositeBuilder createCompositeBuilder(Monitor monitor, AssemblyFactory assemblyFactory, SCABindingFactory scaBindingFactory, + EventBindingFactory eventBindingFactory, EndpointFactory endpointFactory, IntentAttachPointTypeFactory intentAttachPointTypeFactory, DocumentBuilderFactory documentBuilderFactory, @@ -153,6 +155,7 @@ public class ReallySmallRuntimeBuilder { return new CompositeBuilderImpl(assemblyFactory, endpointFactory, scaBindingFactory, + eventBindingFactory, intentAttachPointTypeFactory, documentBuilderFactory, transformerFactory, diff --git a/sandbox/event/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationImpl.java b/sandbox/event/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationImpl.java index 083b01167f..26540f5726 100644 --- a/sandbox/event/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationImpl.java +++ b/sandbox/event/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationImpl.java @@ -23,6 +23,8 @@ import java.util.List; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Consumer; +import org.apache.tuscany.sca.assembly.Producer; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; @@ -92,8 +94,19 @@ public class TestImplementationImpl implements TestImplementation { // The test implementation does not support properties return Collections.emptyList(); } + - public String getURI() { + public List<Consumer> getConsumers() { + // The test implementation does not support consumers + return Collections.emptyList(); + } + + public List<Producer> getProducers() { + // The test implementation does not support producers + return Collections.emptyList(); + } + + public String getURI() { // The test implementation does not have a URI return null; } diff --git a/sandbox/event/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java b/sandbox/event/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java index 11934ec6bb..74a0e2a902 100644 --- a/sandbox/event/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java +++ b/sandbox/event/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java @@ -36,7 +36,9 @@ import javax.xml.stream.XMLStreamWriter; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.ComponentType; import org.apache.tuscany.sca.assembly.ConfiguredOperation; +import org.apache.tuscany.sca.assembly.Consumer; import org.apache.tuscany.sca.assembly.OperationsConfigurator; +import org.apache.tuscany.sca.assembly.Producer; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; @@ -274,6 +276,26 @@ public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaIm } impl.getServices().clear(); impl.getServices().addAll(serviceMap.values()); + + Map<String, Producer> producerMap = new HashMap<String, Producer>(); + for (Producer producer : impl.getProducers()) { + producerMap.put(producer.getName(), producer); + } + for (Producer producer : componentType.getProducers()) { + producerMap.put(producer.getName(), producer); + } + impl.getProducers().clear(); + impl.getProducers().addAll(producerMap.values()); + + Map<String, Consumer> consumerMap = new HashMap<String, Consumer>(); + for (Consumer consumer : impl.getConsumers()) { + consumerMap.put(consumer.getName(), consumer); + } + for (Consumer consumer : componentType.getConsumers()) { + consumerMap.put(consumer.getName(), consumer); + } + impl.getConsumers().clear(); + impl.getConsumers().addAll(consumerMap.values()); Map<String, Property> propMap = new HashMap<String, Property>(); for (Property prop : impl.getProperties()) { diff --git a/sandbox/event/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java b/sandbox/event/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java index 2ad7edbd6f..e30be51aab 100644 --- a/sandbox/event/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java +++ b/sandbox/event/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java @@ -155,6 +155,7 @@ public interface JavaImplementation extends BaseJavaImplementation { */ Map<String, JavaElementImpl> getReferenceMembers(); + /** * @return the scope */ diff --git a/sandbox/event/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationActivator.java b/sandbox/event/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationActivator.java index 46594e0f50..5baea3999a 100644 --- a/sandbox/event/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationActivator.java +++ b/sandbox/event/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationActivator.java @@ -29,6 +29,7 @@ import org.apache.tuscany.sca.implementation.java.introspect.impl.AllowsPassByRe import org.apache.tuscany.sca.implementation.java.introspect.impl.BaseJavaClassVisitor; import org.apache.tuscany.sca.implementation.java.introspect.impl.ComponentNameProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.ConstructorProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.ConsumerProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.ContextProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.ConversationIDProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.ConversationProcessor; @@ -37,6 +38,7 @@ import org.apache.tuscany.sca.implementation.java.introspect.impl.EagerInitProce import org.apache.tuscany.sca.implementation.java.introspect.impl.HeuristicPojoProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.InitProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.PolicyProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.ProducerProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.PropertyProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.ReferenceProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.ResourceProcessor; @@ -70,6 +72,8 @@ public class JavaImplementationActivator implements ModuleActivator { new ReferenceProcessor(assemblyFactory, javaFactory), new ResourceProcessor(assemblyFactory), new ScopeProcessor(assemblyFactory), new ServiceProcessor(assemblyFactory, javaFactory), + new ProducerProcessor(assemblyFactory, javaFactory), + new ConsumerProcessor(assemblyFactory, javaFactory), new HeuristicPojoProcessor(assemblyFactory, javaFactory), new PolicyProcessor(assemblyFactory, policyFactory)}; diff --git a/sandbox/event/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java b/sandbox/event/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java index 375896cf26..bb95fd78ac 100644 --- a/sandbox/event/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java +++ b/sandbox/event/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java @@ -44,6 +44,8 @@ public class JavaImplementationImpl extends BaseJavaImplementationImpl implement private final Map<String, JavaElementImpl> propertyMembers = new HashMap<String, JavaElementImpl>(); private final Map<String, JavaElementImpl> referenceMembers = new HashMap<String, JavaElementImpl>(); private final Map<String, Collection<JavaElementImpl>> callbackMembers = new HashMap<String, Collection<JavaElementImpl>>(); + private final Map<String, Collection<JavaElementImpl>> consumerMembers = new HashMap<String, Collection<JavaElementImpl>>(); + private final Map<String, JavaElementImpl> producerMembers = new HashMap<String, JavaElementImpl>(); private List<Member> conversationIDMember = new ArrayList<Member>(); private boolean eagerInit; private boolean allowsPassByReference; @@ -133,7 +135,15 @@ public class JavaImplementationImpl extends BaseJavaImplementationImpl implement return referenceMembers; } - public JavaScopeImpl getJavaScope() { + public Map<String, Collection<JavaElementImpl>> getConsumerMembers() { + return consumerMembers; + } + + public Map<String, JavaElementImpl> getProducerMembers() { + return producerMembers; + } + + public JavaScopeImpl getJavaScope() { return scope; } diff --git a/sandbox/event/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/builder/impl/NodeCompositeBuilderImpl.java b/sandbox/event/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/builder/impl/NodeCompositeBuilderImpl.java index 736afc13f0..3fcea67451 100644 --- a/sandbox/event/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/builder/impl/NodeCompositeBuilderImpl.java +++ b/sandbox/event/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/builder/impl/NodeCompositeBuilderImpl.java @@ -55,7 +55,7 @@ public class NodeCompositeBuilderImpl extends BaseConfigurationBuilderImpl imple SCADefinitions policyDefinitions, Monitor monitor) { super(assemblyFactory, scaBindingFactory, - null, null, + null, null, null, interfaceContractMapper, policyDefinitions, monitor); } @@ -66,7 +66,7 @@ public class NodeCompositeBuilderImpl extends BaseConfigurationBuilderImpl imple InterfaceContractMapper interfaceContractMapper, SCADefinitions policyDefinitions, Monitor monitor) { - super(assemblyFactory, scaBindingFactory, + super(assemblyFactory, scaBindingFactory, null, documentBuilderFactory, transformerFactory, interfaceContractMapper, policyDefinitions, monitor); } diff --git a/sandbox/event/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/ConfiguredNodeImplementationImpl.java b/sandbox/event/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/ConfiguredNodeImplementationImpl.java index 1d183513b4..7c86446479 100644 --- a/sandbox/event/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/ConfiguredNodeImplementationImpl.java +++ b/sandbox/event/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/ConfiguredNodeImplementationImpl.java @@ -24,6 +24,8 @@ import java.util.List; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Consumer; +import org.apache.tuscany.sca.assembly.Producer; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; @@ -68,6 +70,18 @@ class ConfiguredNodeImplementationImpl implements ConfiguredNodeImplementation { // The node implementation does not support properties return Collections.emptyList(); } + + + + public List<Consumer> getConsumers() { + // The test implementation does not support consumers + return Collections.emptyList(); + } + + public List<Producer> getProducers() { + // The test implementation does not support producers + return Collections.emptyList(); + } public String getURI() { return uri; diff --git a/sandbox/event/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/NodeImplementationImpl.java b/sandbox/event/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/NodeImplementationImpl.java index 8f6315d969..a880c29b17 100644 --- a/sandbox/event/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/NodeImplementationImpl.java +++ b/sandbox/event/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/NodeImplementationImpl.java @@ -23,6 +23,8 @@ import java.util.List; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Consumer; +import org.apache.tuscany.sca.assembly.Producer; import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; @@ -65,6 +67,16 @@ class NodeImplementationImpl implements NodeImplementation { // The node implementation does not support properties return Collections.emptyList(); } + + public List<Consumer> getConsumers() { + // The test implementation does not support consumers + return Collections.emptyList(); + } + + public List<Producer> getProducers() { + // The test implementation does not support producers + return Collections.emptyList(); + } public String getURI() { return uri; diff --git a/sandbox/event/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java b/sandbox/event/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java index 5b0e31fd03..21d4af9d9c 100644 --- a/sandbox/event/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java +++ b/sandbox/event/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBootStrapper.java @@ -33,6 +33,7 @@ import javax.xml.transform.TransformerFactory; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.EndpointFactory; +import org.apache.tuscany.sca.assembly.EventBindingFactory; import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; @@ -218,6 +219,7 @@ public class RuntimeBootStrapper { //Get factory extension point ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class); SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class); + EventBindingFactory eventBindingFactory = factories.getFactory(EventBindingFactory.class); IntentAttachPointTypeFactory intentAttachPointTypeFactory = factories.getFactory(IntentAttachPointTypeFactory.class); EndpointFactory endpointFactory = factories.getFactory(EndpointFactory.class); @@ -235,6 +237,7 @@ public class RuntimeBootStrapper { RuntimeBuilder.createCompositeBuilder(monitor, assemblyFactory, scaBindingFactory, + eventBindingFactory, endpointFactory, intentAttachPointTypeFactory, documentBuilderFactory, diff --git a/sandbox/event/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java b/sandbox/event/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java index 6c93fa7800..2c064ec77e 100644 --- a/sandbox/event/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java +++ b/sandbox/event/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/RuntimeBuilder.java @@ -32,6 +32,7 @@ import javax.xml.transform.TransformerFactory; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.EndpointFactory; +import org.apache.tuscany.sca.assembly.EventBindingFactory; import org.apache.tuscany.sca.assembly.SCABindingFactory; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; @@ -143,6 +144,7 @@ public class RuntimeBuilder { public static CompositeBuilder createCompositeBuilder(Monitor monitor, AssemblyFactory assemblyFactory, SCABindingFactory scaBindingFactory, + EventBindingFactory eventBindingFactory, EndpointFactory endpointFactory, IntentAttachPointTypeFactory intentAttachPointTypeFactory, DocumentBuilderFactory documentBuilderFactory, @@ -150,7 +152,7 @@ public class RuntimeBuilder { InterfaceContractMapper interfaceContractMapper, SCADefinitions policyDefinitions) { - return new CompositeBuilderImpl(assemblyFactory, endpointFactory, scaBindingFactory, + return new CompositeBuilderImpl(assemblyFactory, endpointFactory, scaBindingFactory, eventBindingFactory, intentAttachPointTypeFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper, policyDefinitions, monitor); diff --git a/sandbox/event/modules/sca-api/src/main/java/org/osoa/sca/annotations/EventType.java b/sandbox/event/modules/sca-api/src/main/java/org/osoa/sca/annotations/EventType.java new file mode 100644 index 0000000000..f783e7cb24 --- /dev/null +++ b/sandbox/event/modules/sca-api/src/main/java/org/osoa/sca/annotations/EventType.java @@ -0,0 +1,30 @@ +/* + * (c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA Technologies, + * Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens AG., Software AG., Sybase + * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved. + * + * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications + */ +package org.osoa.sca.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Annotation used to indicate the service interfaces exposed by a Java class. + * + * @version $$ + */ +@Target({TYPE}) +@Retention(RUNTIME) +public @interface EventType { + + /** + * Name of this EventType + * @return + */ + String name() default ""; +} |