blob: 8d0c8e6d3b5c49af0e2a15567b16193df2e9304f [file] [log] [blame]
Title: Event Package
<P>Cayenne includes a full-featured events mechanism. It allows creation of local and distributed event queues. It is very powerful and generic; it is not tied to Cayenne persistence features in any way and can be used in any application. The most important features are:</P>
<UL>
<LI>Event senders do not have to deal with event dispatching details - listener handling and dispatches are done via instances of EventManager.</LI>
<LI>Any types of listeners can be registered. Listeners do not have to implement a specific interface.</LI>
<LI>No explicit unregistering of listeners is required. Listeners are cleaned up when they go out of scope, or when the event subject goes out of scope.</LI>
<LI>Supports local and remote dispatches. Remote dispatches can be done via arbitrary transport by implementing transport-specific EventBridge. There are two existing EventBridge implementations - using JMS and using JavaGroups.</LI>
<LI>Dispatches can be done both synchronously (sender waits till all listeners finish) or asyncronously (sender posts an event to the queue, and returns without waiting for the processing to complete).</LI>
<LI>In a similar manner individual listeners can register as blocking or non-blocking.</LI>
</UL>
<DIV class="panelMacro"><TABLE class="tipMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="http://cayenne.apache.org/docs/1.2/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD>The most common error when using EventSubject is not storing a reference to it. This may result in a premature cleanup of a given subject, and automatic unregistering of all listeners. Good practice is to make subject a &quot;public static final&quot; variable of the event sender class if a subject is common for all instances of senders; or make it an ivar of a sender instance if subject is only related to this instance.</TD></TR></TABLE></DIV>