org.openbp.jaspira.event
Class JaspiraEventMgr

java.lang.Object
  extended by org.openbp.jaspira.event.JaspiraEventMgr

public final class JaspiraEventMgr
extends java.lang.Object

The event manager manages the of global event processing. An event module (EventModule) can designate itself as global event handler. Global event handlers can handle events independently of the plugin tree-based event handling before or after the actual tree-related event handling is performed. The event manager maintains a list of events that should be handled globally and provides methods that perform the event processing for these types of events. The manager is a singleton class that is intended to be used by plugins internally only. In order to fire an event, use either the Plugin.fireEvent(JaspiraEvent) method or one of the fireGlobalEvent(JaspiraEvent) convenience methods provided by this class.

Author:
Jens Ferchland

Field Summary
static java.util.Comparator moduleComparator
          Event module comparator.
 
Method Summary
static boolean fireGlobalEvent(JaspiraEvent je)
          Fires the given event using the application itself as startingpoint.
static boolean fireGlobalEvent(java.lang.String eventname)
          Creates a new client event with the given name and fires it using the application itself as startingpoint.
static boolean fireGlobalEvent(java.lang.String eventname, java.lang.Object data)
          Creates a new client event with the given name and data and fires it using the application itself as startingpoint.
static JaspiraEventMgr getInstance()
          Returns the event manager instance of the system.
 boolean postHandleEvent(JaspiraEvent je)
          Performs the event handling for global events that should be handled after the actual event handling of the plugin.
 boolean preHandleEvent(JaspiraEvent je)
          Performs the event handling for global events that should be handled before the actual event handling of the plugin.
 void registerModule(EventModule module)
          Registers a global event module.
 void unregisterModule(EventModule module)
          Unregisters a global event module.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

moduleComparator

public static java.util.Comparator moduleComparator
Event module comparator. Sorts modules according to their priority.

Method Detail

getInstance

public static JaspiraEventMgr getInstance()
Returns the event manager instance of the system. All global Jaspira events will be managed by this instance.

Returns:
The singleton instance

fireGlobalEvent

public static boolean fireGlobalEvent(JaspiraEvent je)
Fires the given event using the application itself as startingpoint. Merely a convenience method for ApplicationBase.getInstance ().fireEvent (JaspiraEvent).

Parameters:
je - The event to fire
Returns:
true If the event was consumed by a plugin
false Otherwise

fireGlobalEvent

public static boolean fireGlobalEvent(java.lang.String eventname)
Creates a new client event with the given name and fires it using the application itself as startingpoint. Merely a convenience method for ApplicationBase.getInstance().fireEvent (String).

Parameters:
eventname - The name for the event
Returns:
true If the event was consumed by a plugin
false Otherwise

fireGlobalEvent

public static boolean fireGlobalEvent(java.lang.String eventname,
                                      java.lang.Object data)
Creates a new client event with the given name and data and fires it using the application itself as startingpoint. Merely a convenience method for ApplicationBase.getInstance().fireEvent (String, Object).

Parameters:
eventname - The name for the event
data - The dataobject for the event
Returns:
true If the event was consumed by a plugin
false Otherwise

preHandleEvent

public boolean preHandleEvent(JaspiraEvent je)
Performs the event handling for global events that should be handled before the actual event handling of the plugin. To be called by the AbstractPlugin class only.

Parameters:
je - EVent to handle
Returns:
true The event was consumed by an event handler.
false The event is not a global pre-handled event or was not consumed by the handler.

postHandleEvent

public boolean postHandleEvent(JaspiraEvent je)
Performs the event handling for global events that should be handled after the actual event handling of the plugin. To be called by the AbstractPlugin class only.

Parameters:
je - EVent to handle
Returns:
true The event was consumed by an event handler.
false The event is not a global post-handled event or was not consumed by the handler.

registerModule

public void registerModule(EventModule module)
Registers a global event module.


unregisterModule

public void unregisterModule(EventModule module)
Unregisters a global event module.



Copyright © 2011. All Rights Reserved.