Interface ListenersRegistry
-
public interface ListenersRegistry
Allows to register before and after listeners for system events on all persistable entities in the application. Below is an example illustrating registration of a callback to be triggered after any commit action in the application.Core.getListenersRegistry().registerAfterCommitListener(objs -> { //pre-process entities that were committed });
The callback represents a
Consumer
with its argument representing the entities which are subject to the mentioned action. In this case, it is aList
of @IMendixObject
that were committed. The registration of a callback can be done in a custom Java action. Once registered the callback in the example will be executed for every commit of any persistable entity in the application. So, usually entities should be filtered, e.g. by type, to avoid executing the logic inside the callback for any entity that is being committed in the application and thus reducing performance of the application.A word of caution: it is not recommended to commit any Persistence Entities in the callbacks passed to
registerAfterCommitListener(Consumer)
orregisterBeforeCommitListener(Consumer)
since this will trigger the listeners to be executed again thus leading to an infinite loop.- Since:
- 7.6
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends CoreAction<?>>
voidaddListener(ActionListener<T> actionListener)
Registers the given ActionListener to the ActionManager.void
registerAfterChangeListener(java.util.function.Consumer<IMendixObject> action)
Registers an after-change callback.void
registerAfterCommitListener(java.util.function.Consumer<java.util.List<IMendixObject>> action)
Registers an after-commit callback.void
registerAfterCreateListener(java.util.function.Consumer<IMendixObject> action)
Registers an after-create callback.void
registerAfterDeleteListener(java.util.function.Consumer<java.util.List<IMendixObject>> action)
Registers an after-delete callback.void
registerBeforeChangeListener(java.util.function.Consumer<IMendixObject> action)
Registers a before-change callback.void
registerBeforeCommitListener(java.util.function.Consumer<java.util.List<IMendixObject>> action)
Registers a before-commit callback.void
registerBeforeCreateListener(java.util.function.Consumer<IMendixObject> action)
Registers a before-create callback.void
registerBeforeDeleteListener(java.util.function.Consumer<java.util.List<IMendixObject>> action)
Registers a before-delete callback.
-
-
-
Method Detail
-
addListener
<T extends CoreAction<?>> void addListener(ActionListener<T> actionListener)
Registers the given ActionListener to the ActionManager.- Type Parameters:
T
- the result type of the action- Parameters:
actionListener
- the ActionListener to add
-
registerAfterCommitListener
void registerAfterCommitListener(java.util.function.Consumer<java.util.List<IMendixObject>> action)
Registers an after-commit callback.- Parameters:
action
- aConsumer
.List<IMendixObject>
type parameter is the list of entities which were committed.
-
registerBeforeCommitListener
void registerBeforeCommitListener(java.util.function.Consumer<java.util.List<IMendixObject>> action)
Registers a before-commit callback.- Parameters:
action
- aConsumer
instance.List<IMendixObject>
type parameter is the list of entities which are to be committed.
-
registerAfterDeleteListener
void registerAfterDeleteListener(java.util.function.Consumer<java.util.List<IMendixObject>> action)
Registers an after-delete callback.- Parameters:
action
- aConsumer
instance.List<IMendixObject>
type parameter is the list of entities which are deleted.
-
registerBeforeDeleteListener
void registerBeforeDeleteListener(java.util.function.Consumer<java.util.List<IMendixObject>> action)
Registers a before-delete callback.- Parameters:
action
- aConsumer
instance.List<IMendixObject>
type parameter is the list of entities which are to be deleted.
-
registerAfterCreateListener
void registerAfterCreateListener(java.util.function.Consumer<IMendixObject> action)
Registers an after-create callback.- Parameters:
action
- aConsumer
instance.IMendixObject
type parameter is the entity that was created
-
registerBeforeCreateListener
void registerBeforeCreateListener(java.util.function.Consumer<IMendixObject> action)
Registers a before-create callback.- Parameters:
action
- aConsumer
instance.IMendixObject
type parameter is the entity that is to be created. The IMendixObject instance will always be null, because the object is not yet created.
-
registerAfterChangeListener
void registerAfterChangeListener(java.util.function.Consumer<IMendixObject> action)
Registers an after-change callback.- Parameters:
action
- aConsumer
instance.IMendixObject
is the entity that has been changed
-
registerBeforeChangeListener
void registerBeforeChangeListener(java.util.function.Consumer<IMendixObject> action)
Registers a before-change callback.- Parameters:
action
- aConsumer
instance.IMendixObject
is the entity that is being changed
-
-