com.ibm.connections.spi.events
Interface PreEventHandler

All Known Implementing Classes:
AbstractPreEventHandler

public interface PreEventHandler

Pre Event handlers can be registered to receive events as and when they are generated by IBM Connections. Pre Event handlers are invoked synchronously at a point where the event object they receive is mutable and the handler can modify certain contents. Not all event data can be modified. Implementations of this interface should be valid JavaBeans which provide a public default constructor and public getters and setters for any properties. Only simple properties are supported. The lifecycle of an event handler is as follows:

  1. The handler is instantiated by the runtime by calling the default constructor
  2. Any configured properties are set on the handler. The runtime will call the setter for any configured properties
  3. The runtime will invoke the init method. The handler implementation should validate any property values. If any configuration is invalid it should throw an EventHandlerInitException
  4. Once successfully initialized, the runtime will begin invocation of the handleEvent method as events occur. This method may be called multiple times during the lifecycle of any handler instance. If the handler encounters any issue during invocation it should throw an EventHandlerException
  5. At some point, the runtime may invoke destroy to inform the handler that no more events will be consumed. The handler should release any held resources and clean up
A few rules:


Method Summary
 void destroy()
          Called whenever the application is stopping, to allow handlers to clean up.
 void handleEvent(MutableEvent event)
          This method will be called whenever an event for which this handler is registered is consumed.
 void init()
          Will be invoked by IBM Connections after instantiating an instance of this event handler.
 

Method Detail

init

void init()
          throws EventHandlerInitException
Will be invoked by IBM Connections after instantiating an instance of this event handler. The implementation of this method should validate the handler configuration and throw an EventHandlerInitException if there are any problems. This exception will be logged appropriately, but will not stop the generation and sending of events or otherwise affect the running of the system. It will however mean that this handler will not be invoked subsequently.

Throws:
EventHandlerInitException - if the handler does not initialize successfully. This will be logged by the runtime.

handleEvent

void handleEvent(MutableEvent event)
                 throws EventHandlerException
This method will be called whenever an event for which this handler is registered is consumed.

Parameters:
event - the event to be handled. This event is mutable.
Throws:
EventHandlerException - if the handling of an event fails. This will be logged.

destroy

void destroy()
Called whenever the application is stopping, to allow handlers to clean up.