Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2008 BEA Systems, Inc. All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.p13n.events
Interface EventListener

All Known Implementing Classes:
  BehaviorTrackingListener

    public interface EventListener

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 based on the Event type. 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 notifies all EventListeners synchronously (although in no particular order) calling handleEvent() upon each EventListener on the same thread.

An AsychronousEvenService may be configured with (the same) EventListeners, as an alternative. The only difference is in this case a separate thread from a thread pool is used. One thread per event (not per EventListener).

Thus, every effort should still 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();
       }

See Also
  `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

### getTypes

    String[] getTypes()

  This method lets the EventListener advertise what types it is interested in. It is used by the EventHandler to dispatch only Events with a matching type to this EventListener. To listen on all events, implement this method to return a String[1] containing EventConstants.TYPE_ALL. Must not return null or return null in any element.

  Returns
    Array of Strings enumerating each Event type this listener is interested in.

### handleEvent

    void handleEvent(Event theEvent)

  Implement this method to "do the action" that is required when an event is dispatched to the EventHandler. This method will be called whenever an Event's type matches one of the types returned by getTypes().

  Parameters
    `theEvent` - the event that happened.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008 BEA Systems, Inc. All Rights Reserved