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=6&revisedVersion=7






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 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}

{code}

h2. Event Producers

Event Producers are identified as a Field or as 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}


h2. Event Types

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

h2. Example Java Implementation with Consumer and Producer


h3.  

---------------------------------------------------------------------
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