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

## com.bea.p13n.events
Interface EventListener

All Known Subinterfaces:
  ConfigurableEventListener

All Known Implementing Classes:
  BehaviorTrackingListener, DebugEventListener

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. 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();
       }

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

    public 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

    public 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
| © 2004 BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004 BEA Systems, Inc. All Rights Reserved