Class MCREventManager

java.lang.Object
org.mycore.common.events.MCREventManager

public class MCREventManager extends Object
Acts as a multiplexer to forward events that are created to all registered event handlers, in the order that is configured in mycore properties. For information how to configure, see MCREventHandler javadocs.
Author:
Frank Lützenkirchen
See Also:
  • Field Details

    • CONFIG_PREFIX

      public static final String CONFIG_PREFIX
      See Also:
    • FORWARD

      public static final boolean FORWARD
      Call event handlers in forward direction (create, update)
      See Also:
    • BACKWARD

      public static final boolean BACKWARD
      Call event handlers in backward direction (delete)
      See Also:
  • Method Details

    • instance

      public static MCREventManager instance()
      The singleton manager instance
      Returns:
      the single event manager
    • handleEvent

      public void handleEvent(MCREvent evt, boolean direction)
      This method is called by the component that created the event and acts as a multiplexer that invokes all registered event handlers doHandleEvent methods. If something goes wrong and an exception is caught, the undoHandleEvent methods of all event handlers that are at a position BEFORE the failed one, will be called in reversed order. The parameter direction controls the order in which the event handlers are called.
      Parameters:
      evt - the event that happened
      direction - the order in which the event handlers are called
      See Also:
    • handleEvent

      public void handleEvent(MCREvent evt) throws MCRException
      Same as handleEvent( evt, MCREventManager.FORWARD )
      Throws:
      MCRException
    • addEventHandler

      public MCREventManager addEventHandler(MCREvent.ObjectType type, MCREventHandler handler)
      Appends the event handler to the end of the list.
      Parameters:
      type - type of event e.g. MCRObject
    • addEventHandler

      public MCREventManager addEventHandler(MCREvent.ObjectType type, MCREventHandler handler, int index)
      Inserts the event handler at the specified position.
      Parameters:
      type - type of event e.g. MCRObject
      index - index at which the specified element is to be inserted
    • removeEventHandler

      public MCREventManager removeEventHandler(MCREvent.ObjectType type, MCREventHandler handler)
      Removes the specified event handler.
      Parameters:
      type - type of event handler
      handler - the event handler to remove
    • removeEventHandler

      public MCREventManager removeEventHandler(MCREvent.ObjectType type)
      Removes all event handler of the specified type.
      Parameters:
      type - type to removed
    • clear

      public MCREventManager clear()
      Clears the MCREventManager so that it contains no MCREventHandler.
    • getEventHandler

      public MCREventHandler getEventHandler(String mode, String propertyValue)