From 200a40b332420f94992eb39a6d0ea1cf1490ffc4 Mon Sep 17 00:00:00 2001 From: coreyg Date: Fri, 21 Nov 2014 09:30:19 +0000 Subject: Adding tuscany's website to their svn repo for svnpubsub git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1640879 13f79535-47bb-0310-9956-ffa450edef68 --- ...-implementation-model-for-event-processing.html | 207 +++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 site/trunk/site-publish/java-implementation-model-for-event-processing.html (limited to 'site/trunk/site-publish/java-implementation-model-for-event-processing.html') diff --git a/site/trunk/site-publish/java-implementation-model-for-event-processing.html b/site/trunk/site-publish/java-implementation-model-for-event-processing.html new file mode 100644 index 0000000000..f1e560b58a --- /dev/null +++ b/site/trunk/site-publish/java-implementation-model-for-event-processing.html @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + Apache Tuscany : Java Implementation Model for Event Processing + + + + + + + + + + + + + + + +
+ + + + +   + +
+ + +
+
+ + + + + + + + + +
+  Apache Tuscany > Home > SCA Overview > SCA Java > Java SCA Documentation Menu > SCA Java Event Processing > Java Implementation Model for Event Processing + + User List | Dev List | Issue Tracker   +
+ + + + + + + +
+ + +
+ +
+
+

This page describes the Java Implementation for Event Processing.

+ +

The Java Implementation for Event Processing is an extension of the standard SCA Java Implementation model. All the standard SCA Java implementation features continue to be available to Java implementations. The following features are added:

+
    +
  • Ability to define one or more methods of the implementation class to be consumer methods, consuming one or more event types
  • +
  • Ability to define a field or setter method of the implementation class as an event producer, with one or more business methods producing one or more event types 
  • +
  • Ability to define event types as Java POJO classes
  • +
+ + +

Event Types

+ +

Event types are defined through Java classes which are annotated with a @EventType annotation.  The @EventType annotation has a single parameter which is the name of the event type.

+
+
@EventType(ExampleEvent)
+public class ExampleEvent {
+
+     public String eventData;
+
+} // end class ExampleEvent
+
+
+

The name may be:

+
    +
  • unqualified, in which case the EventType name is qualified by the package name of the class itself
  • +
  • qualified, in which case the EventType name is used as it is declared
  • +
+ + +

Note that the Event Type name maps to an XSD QName using the Java-to-WSDL mapping as defined by JAX-WS.

+ +

The Event type(s) handled by a consumer method or a producer method is defined in one of two ways:

+
    +
  1. The method has a parameter that is of a class annotated with the @EventType annotation (of a single event type)
  2. +
  3. The method is itself annotated with the @EventTypes annotation for one or more event types - where the method parameter is of some generic type such as java.lang.Object which does not specify an EventType
  4. +
+ + +

Event Consumer methods

+ +

Each method of the implementation that is a consumer for events is annotated with a @Consumer annotation.  Each method must have a void return type and a single parameter that is either a specific event type or a superclass of one or more event types, including java.lang.Object, which is treated as the supertype of all event types.

+
+
public class ConsumerrExample {
+
+    private ExampleProducer eventProducer;
+
+    @Consumer(ExampleConsumer)
+    public void someBusinessMethod( ExampleEvent theEvent ) {
+        String businessData = theEvent.eventData;
+        // do business processing...
+    } // end method someBusinessMethod
+
+} // end class
+
+
+ +

Event Producers

+ +

Event Producers are identified as a Field or a Setter method annotated with a @Producer annotation

+ +

It is required that the Field or Setter method is typed by a Java interface.  The Java interface must have one or more methods, each of which has a void return type and a single parameter that is either a specific event type or a superclass of one or more event types, including java.lang.Object, which is treated as the supertype of all event types.

+
+
@Remotable
+public interface ExampleProducer {
+
+    void produceExampleEvent( ExampleEvent theEvent);
+
+} // end interface ExampleProducer
+
+@EventType(ExampleEvent)
+public class ExampleEvent {
+
+     public String eventData;
+
+} // end class ExampleEvent
+
+
+public class ProducerExample {
+
+    private ExampleProducer eventProducer;
+
+    @Producer(ExampleEvent)
+    public void setEventProducer( ExampleProducer theProducer ) {
+        eventProducer = theProducer;
+        return;
+    } // end method setEventProducer
+
+    public void someBusinessMethod() {
+        theEvent = new ExampleEvent();
+        theEvent.eventData = "Some Data";
+        eventProducer.produceExampleEvent( theEvent );
+    } // end method someBusinessMethod
+
+} // end class
+
+
+
+
+
+ + +
+ + + + + + website stats + + + + + + -- cgit v1.2.3