Package org.mycore.common.events
Class MCREventManager
java.lang.Object
org.mycore.common.events.MCREventManager
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:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
Call event handlers in backward direction (delete)static final String
static final boolean
Call event handlers in forward direction (create, update) -
Method Summary
Modifier and TypeMethodDescriptionaddEventHandler
(MCREvent.ObjectType type, MCREventHandler handler) Appends the event handler to the end of the list.addEventHandler
(MCREvent.ObjectType type, MCREventHandler handler, int index) Inserts the event handler at the specified position.clear()
Clears theMCREventManager
so that it contains noMCREventHandler
.getEventHandler
(String mode, String propertyValue) void
handleEvent
(MCREvent evt) Same as handleEvent( evt, MCREventManager.FORWARD )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.static MCREventManager
instance()
The singleton manager instanceRemoves all event handler of the specified type.removeEventHandler
(MCREvent.ObjectType type, MCREventHandler handler) Removes the specified event handler.
-
Field Details
-
CONFIG_PREFIX
- See Also:
-
FORWARD
public static final boolean FORWARDCall event handlers in forward direction (create, update)- See Also:
-
BACKWARD
public static final boolean BACKWARDCall event handlers in backward direction (delete)- See Also:
-
-
Method Details
-
instance
The singleton manager instance- Returns:
- the single event manager
-
handleEvent
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 happeneddirection
- the order in which the event handlers are called- See Also:
-
handleEvent
Same as handleEvent( evt, MCREventManager.FORWARD )- Throws:
MCRException
-
addEventHandler
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. MCRObjectindex
- index at which the specified element is to be inserted
-
removeEventHandler
Removes the specified event handler.- Parameters:
type
- type of event handlerhandler
- the event handler to remove
-
removeEventHandler
Removes all event handler of the specified type.- Parameters:
type
- type to removed
-
clear
Clears theMCREventManager
so that it contains noMCREventHandler
. -
getEventHandler
-