Class ValidatingRepositoryEventListener
java.lang.Object
org.springframework.data.rest.core.event.AbstractRepositoryEventListener<Object>
org.springframework.data.rest.core.event.ValidatingRepositoryEventListener
- All Implemented Interfaces:
EventListener
,ApplicationListener<RepositoryEvent>
- Author:
- Jon Brisbin, Oliver Gierke
-
Constructor Summary
ConstructorDescriptionValidatingRepositoryEventListener
(ObjectFactory<PersistentEntities> persistentEntitiesFactory) Creates a newValidatingRepositoryEventListener
using the given repositories. -
Method Summary
Modifier and TypeMethodDescriptionaddValidator
(String event, Validator validator) Add aValidator
that will be triggered on the given event.protected void
onAfterCreate
(Object entity) Override this method if you are interested in afterCreate events.protected void
onAfterDelete
(Object entity) Override this method if you are interested in afterDelete events.protected void
onAfterLinkSave
(Object parent, Object linked) Override this method if you are interested in afterLinkSave events.protected void
onAfterSave
(Object entity) Override this method if you are interested in afterSave events.protected void
onBeforeCreate
(Object entity) Override this method if you are interested in beforeCreate events.protected void
onBeforeDelete
(Object entity) Override this method if you are interested in beforeDelete events.protected void
onBeforeLinkSave
(Object parent, Object linked) Override this method if you are interested in beforeLinkSave events.protected void
onBeforeSave
(Object entity) Override this method if you are interested in beforeSave events.setValidators
(Map<String, Collection<Validator>> validators) Assign a Map ofValidator
s that are assigned to the variousRepositoryEvent
s.Methods inherited from class org.springframework.data.rest.core.event.AbstractRepositoryEventListener
onAfterLinkDelete, onApplicationEvent, onBeforeLinkDelete
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Constructor Details
-
ValidatingRepositoryEventListener
public ValidatingRepositoryEventListener(ObjectFactory<PersistentEntities> persistentEntitiesFactory) Creates a newValidatingRepositoryEventListener
using the given repositories.- Parameters:
persistentEntitiesFactory
- must not be null.
-
-
Method Details
-
setValidators
public ValidatingRepositoryEventListener setValidators(Map<String, Collection<Validator>> validators) Assign a Map ofValidator
s that are assigned to the variousRepositoryEvent
s.- Parameters:
validators
- A Map of Validators to wire.- Returns:
-
addValidator
Add aValidator
that will be triggered on the given event.- Parameters:
event
- The event to listen for.validator
- The Validator to execute when that event fires.- Returns:
-
onBeforeCreate
Description copied from class:AbstractRepositoryEventListener
Override this method if you are interested in beforeCreate events.- Overrides:
onBeforeCreate
in classAbstractRepositoryEventListener<Object>
- Parameters:
entity
- The entity being created.
-
onAfterCreate
Description copied from class:AbstractRepositoryEventListener
Override this method if you are interested in afterCreate events.- Overrides:
onAfterCreate
in classAbstractRepositoryEventListener<Object>
- Parameters:
entity
- The entity that was created.
-
onBeforeSave
Description copied from class:AbstractRepositoryEventListener
Override this method if you are interested in beforeSave events.- Overrides:
onBeforeSave
in classAbstractRepositoryEventListener<Object>
- Parameters:
entity
- The entity being saved.
-
onAfterSave
Description copied from class:AbstractRepositoryEventListener
Override this method if you are interested in afterSave events.- Overrides:
onAfterSave
in classAbstractRepositoryEventListener<Object>
- Parameters:
entity
- The entity that was just saved.
-
onBeforeLinkSave
Description copied from class:AbstractRepositoryEventListener
Override this method if you are interested in beforeLinkSave events.- Overrides:
onBeforeLinkSave
in classAbstractRepositoryEventListener<Object>
- Parameters:
parent
- The parent entity to which the child object is linked.linked
- The linked, child entity.
-
onAfterLinkSave
Description copied from class:AbstractRepositoryEventListener
Override this method if you are interested in afterLinkSave events.- Overrides:
onAfterLinkSave
in classAbstractRepositoryEventListener<Object>
- Parameters:
parent
- The parent entity to which the child object is linked.linked
- The linked, child entity.
-
onBeforeDelete
Description copied from class:AbstractRepositoryEventListener
Override this method if you are interested in beforeDelete events.- Overrides:
onBeforeDelete
in classAbstractRepositoryEventListener<Object>
- Parameters:
entity
- The entity that is being deleted.
-
onAfterDelete
Description copied from class:AbstractRepositoryEventListener
Override this method if you are interested in afterDelete events.- Overrides:
onAfterDelete
in classAbstractRepositoryEventListener<Object>
- Parameters:
entity
- The entity that was just deleted.
-