From e753f271ccf0ff4617725130b82dd21ae721b3d2 Mon Sep 17 00:00:00 2001 From: rsivaram Date: Tue, 21 Oct 2008 09:04:28 +0000 Subject: Event prototype: Initial model changes git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@706556 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/assembly/xml/CompositeProcessor.java | 120 ++++++++++ .../apache/tuscany/sca/assembly/xml/Constants.java | 6 + .../assembly-xsd/src/main/resources/sca-core.xsd | 84 ++++++- .../tuscany/sca/assembly/AssemblyFactory.java | 44 ++++ .../org/apache/tuscany/sca/assembly/Component.java | 14 ++ .../apache/tuscany/sca/assembly/ComponentType.java | 15 ++ .../builder/impl/BaseConfigurationBuilderImpl.java | 86 ++++++++ .../impl/ComponentConfigurationBuilderImpl.java | 21 +- .../impl/CompositeBindingURIBuilderImpl.java | 20 +- .../builder/impl/CompositeBuilderImpl.java | 13 +- .../sca/assembly/impl/AssemblyFactoryImpl.java | 32 +++ .../tuscany/sca/assembly/impl/ComponentImpl.java | 12 + .../sca/assembly/impl/ComponentTypeImpl.java | 14 ++ .../event/EventBindingDefinitionsProvider.java | 73 +++++++ .../event/impl/EventBindingFactoryImpl.java | 40 ++++ .../sca/binding/event/impl/EventBindingImpl.java | 243 +++++++++++++++++++++ .../binding/event/impl/EventBindingInvoker.java | 72 ++++++ .../binding/event/impl/EventBindingProvider.java | 60 +++++ .../event/impl/EventBindingProviderFactory.java | 60 +++++ .../event/impl/EventReferenceBindingProvider.java | 97 ++++++++ .../event/impl/EventServiceBindingProvider.java | 63 ++++++ ...apache.tuscany.sca.assembly.EventBindingFactory | 18 ++ ...che.tuscany.sca.provider.BindingProviderFactory | 19 ++ ...che.tuscany.sca.provider.SCADefinitionsProvider | 19 ++ .../apache/tuscany/sca/binding/sca/definitions.xml | 26 +++ .../helper/utils/AbstractImplementation.java | 14 ++ .../sca/host/embedded/impl/ReallySmallRuntime.java | 3 + .../embedded/impl/ReallySmallRuntimeBuilder.java | 3 + .../extension/impl/TestImplementationImpl.java | 15 +- .../java/xml/JavaImplementationProcessor.java | 22 ++ .../implementation/java/JavaImplementation.java | 1 + .../java/impl/JavaImplementationActivator.java | 4 + .../java/impl/JavaImplementationImpl.java | 12 +- .../builder/impl/NodeCompositeBuilderImpl.java | 4 +- .../impl/ConfiguredNodeImplementationImpl.java | 14 ++ .../node/impl/NodeImplementationImpl.java | 12 + .../tuscany/sca/node/impl/RuntimeBootStrapper.java | 3 + .../tuscany/sca/node/impl/RuntimeBuilder.java | 4 +- .../java/org/osoa/sca/annotations/EventType.java | 30 +++ .../src/main/java/weather/WeatherPublisher.java | 5 + .../java/weather/WeatherPublisherComponent.java | 4 +- .../java/weather/WeatherSubscriberComponent.java | 4 +- .../src/main/resources/weatherPublisher.composite | 4 + .../src/main/resources/weatherSubscriber.composite | 4 + .../src/test/java/weather/WeatherTestCase.java | 20 +- 45 files changed, 1430 insertions(+), 23 deletions(-) create mode 100644 sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/EventBindingDefinitionsProvider.java create mode 100644 sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingFactoryImpl.java create mode 100644 sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingImpl.java create mode 100644 sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingInvoker.java create mode 100644 sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingProvider.java create mode 100644 sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventBindingProviderFactory.java create mode 100644 sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventReferenceBindingProvider.java create mode 100644 sandbox/event/modules/binding-event/src/main/java/org/apache/tuscany/sca/binding/event/impl/EventServiceBindingProvider.java create mode 100644 sandbox/event/modules/binding-event/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EventBindingFactory create mode 100644 sandbox/event/modules/binding-event/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 sandbox/event/modules/binding-event/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider create mode 100644 sandbox/event/modules/binding-event/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml create mode 100644 sandbox/event/modules/sca-api/src/main/java/org/osoa/sca/annotations/EventType.java (limited to 'sandbox/event') 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 + 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 + 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 + 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 + 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 @@ - + + + @@ -147,6 +151,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -190,7 +229,9 @@ - + + + + + + + \ 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 services = new ArrayList(); private List references = new ArrayList(); + private List producers = new ArrayList(); + private List consumers = new ArrayList(); private List properties = new ArrayList(); private ConstrainingType constrainingType; private String uri; @@ -66,6 +70,16 @@ public abstract class AbstractImplementation implements Implementation { public List getServices() { return services; } + + + public List getProducers() { + return producers; + } + + public List 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 getConsumers() { + // The test implementation does not support consumers + return Collections.emptyList(); + } + + public List 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 producerMap = new HashMap(); + 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 consumerMap = new HashMap(); + 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 propMap = new HashMap(); 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 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 propertyMembers = new HashMap(); private final Map referenceMembers = new HashMap(); private final Map> callbackMembers = new HashMap>(); + private final Map> consumerMembers = new HashMap>(); + private final Map producerMembers = new HashMap(); private List conversationIDMember = new ArrayList(); private boolean eagerInit; private boolean allowsPassByReference; @@ -133,7 +135,15 @@ public class JavaImplementationImpl extends BaseJavaImplementationImpl implement return referenceMembers; } - public JavaScopeImpl getJavaScope() { + public Map> getConsumerMembers() { + return consumerMembers; + } + + public Map 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 getConsumers() { + // The test implementation does not support consumers + return Collections.emptyList(); + } + + public List 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 getConsumers() { + // The test implementation does not support consumers + return Collections.emptyList(); + } + + public List 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 ""; +} diff --git a/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisher.java b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisher.java index 7ef72d10b1..cdaabd9f54 100644 --- a/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisher.java +++ b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisher.java @@ -18,6 +18,11 @@ */ package weather; +import org.osoa.sca.annotations.Remotable; + +// FIXME: At the moment, we need this @Remotable to make sure all the processing +// is done properly +@Remotable public interface WeatherPublisher { void publishWeatherReport(String report); diff --git a/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java index 658229799d..23c52400e8 100644 --- a/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java +++ b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java @@ -31,7 +31,7 @@ import org.osoa.sca.annotations.Service; public class WeatherPublisherComponent implements WeatherService { @Producer - public WeatherPublisher publisher; + public WeatherPublisher weatherPublisher; public void start() { try { @@ -47,7 +47,7 @@ public class WeatherPublisherComponent implements WeatherService { int temperature = new Random().nextInt(20); String report = "Location: New York, Time: " + new Date() + ", Temperature " + temperature; - publisher.publishWeatherReport(report); + weatherPublisher.publishWeatherReport(report); } } diff --git a/sandbox/event/samples/event-jms/src/main/java/weather/WeatherSubscriberComponent.java b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherSubscriberComponent.java index eb9185a70e..2d8d17260e 100644 --- a/sandbox/event/samples/event-jms/src/main/java/weather/WeatherSubscriberComponent.java +++ b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherSubscriberComponent.java @@ -21,13 +21,15 @@ package weather; import java.util.Date; import org.osoa.sca.annotations.Consumer; +import org.osoa.sca.annotations.Remotable; /** * The WeatherService subscriber implementation - receives weather reports and prints it on stdout */ -public class WeatherSubscriberComponent { +@Remotable +public class WeatherSubscriberComponent { @Consumer(name="weatherSubscriber") public void onWeather(String report) { diff --git a/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite b/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite index 6b2e59dc8f..8c1e84adfc 100644 --- a/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite +++ b/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite @@ -31,6 +31,10 @@ + + + diff --git a/sandbox/event/samples/event-jms/src/main/resources/weatherSubscriber.composite b/sandbox/event/samples/event-jms/src/main/resources/weatherSubscriber.composite index eac1b242ea..b4fcae1565 100644 --- a/sandbox/event/samples/event-jms/src/main/resources/weatherSubscriber.composite +++ b/sandbox/event/samples/event-jms/src/main/resources/weatherSubscriber.composite @@ -28,6 +28,10 @@ + + + diff --git a/sandbox/event/samples/event-jms/src/test/java/weather/WeatherTestCase.java b/sandbox/event/samples/event-jms/src/test/java/weather/WeatherTestCase.java index a251de53c2..dfff7cc666 100644 --- a/sandbox/event/samples/event-jms/src/test/java/weather/WeatherTestCase.java +++ b/sandbox/event/samples/event-jms/src/test/java/weather/WeatherTestCase.java @@ -20,6 +20,7 @@ package weather; +import org.apache.activemq.broker.BrokerService; import org.apache.tuscany.sca.host.embedded.SCADomain; import org.junit.After; import org.junit.Before; @@ -33,14 +34,19 @@ import weather.WeatherService; */ public class WeatherTestCase { + private BrokerService jmsBroker; + private WeatherService weatherService; private SCADomain weatherSubscriberDomain; private SCADomain weatherPublisherDomain; @Before - public void startClient() throws Exception { + public void startWeatherTest() throws Exception { try { + + startBroker(); + weatherPublisherDomain = SCADomain.newInstance("weatherPublisher.composite"); weatherSubscriberDomain = SCADomain.newInstance("weatherSubscriber.composite"); weatherService = weatherPublisherDomain.getService(WeatherService.class, "WeatherPublisherComponent"); @@ -51,7 +57,7 @@ public class WeatherTestCase { } @Test - public void testClient() throws Exception { + public void runWeatherTest() throws Exception { weatherService.start(); } @@ -62,5 +68,13 @@ public class WeatherTestCase { weatherSubscriberDomain.close(); } - + + + protected void startBroker() throws Exception { + jmsBroker = new BrokerService(); + jmsBroker.setPersistent(false); + jmsBroker.setUseJmx(false); + jmsBroker.addConnector("tcp://localhost:61619"); + jmsBroker.start(); + } } -- cgit v1.2.3