Java Implementation Model for Event Processing (TUSCANY) edited by Mike Edwards
      Page: 
http://cwiki.apache.org/confluence/display/TUSCANY/Java+Implementation+Model+for+Event+Processing
   Changes: 
http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=99635&originalVersion=10&revisedVersion=11






Content:
---------------------------------------------------------------------

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

h2. 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.
{code}
@EventType(ExampleEvent)
public class ExampleEvent {

     public String eventData;

} // end class ExampleEvent
{code}
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:
# The method has a parameter that is of a class annotated with the @EventType 
annotation (of a single event type)
# 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

h2. 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.
{code}
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
{code}

h2. 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.
{code}
@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
{code}

---------------------------------------------------------------------
CONFLUENCE INFORMATION
This message is automatically generated by Confluence

Unsubscribe or edit your notifications preferences
   http://cwiki.apache.org/confluence/users/viewnotifications.action

If you think it was sent incorrectly contact one of the administrators
   http://cwiki.apache.org/confluence/administrators.action

If you want more information on Confluence, or have a bug to report see
   http://www.atlassian.com/software/confluence


Reply via email to