|
© 2005 BEA Systems, Inc. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Event Listener. Implementations of this interface can handle events dispatched to an EventHandler.
An Event Listener expresses interest in handling some set of Event types by implementing getTypes() to return the Event type names that it should handle. The EventHandler is responsible for dispatching incoming Events to registered listeners. The default implementation of the EventHandler is the EventService EJB Session Bean.
Any Events dispatched to the EventHandler are sent to registered EventListeners handleEvent() method. Implement this method to do the action required when the event occurs. The EventService implementation processes these handleEvent methods synchronously (although in no particular order). Thus, every effort must be made to have the handleEvent methods as efficient as possible. If some action is to take a significant amount of time or other resources, consider making handleEvent asynchronous via some service such as JMS.
NOTE: All implementations of EventListener are required to
have a no-args constructor - i.e. so that new EventListener()
will work.
EventListener implementations should implement equals() is such a way that multiple listeners will not be added to the same handler. Simple listeners (where any instance of the class is equivalent to any other) may want to use the following implementaion.
public boolean equals( Object theOther ) { // Consider listeners of the same class as equivalent return theOther != null && theOther.getClass() == this.getClass(); }
Event
,
for description of how to register listeners with the
EventService.
Method Summary | |
String[] |
getTypes()
This method lets the EventListener advertise what types it is interested in. |
void |
handleEvent(Event theEvent)
Implement this method to "do the action" that is required when an event is dispatched to the EventHandler. |
Method Detail |
public String[] getTypes()
public void handleEvent(Event theEvent)
theEvent
- the event that happened.
|
© 2005 BEA Systems, Inc. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |