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
ConstructorsConstructorDescriptionValidatingRepositoryEventListener(ObjectFactory<PersistentEntities> persistentEntitiesFactory) Creates a newValidatingRepositoryEventListenerusing the given repositories. -
Method Summary
Modifier and TypeMethodDescriptionaddValidator(String event, Validator validator) Add aValidatorthat will be triggered on the given event.protected voidonAfterCreate(Object entity) Override this method if you are interested in afterCreate events.protected voidonAfterDelete(Object entity) Override this method if you are interested in afterDelete events.protected voidonAfterLinkSave(Object parent, Object linked) Override this method if you are interested in afterLinkSave events.protected voidonAfterSave(Object entity) Override this method if you are interested in afterSave events.protected voidonBeforeCreate(Object entity) Override this method if you are interested in beforeCreate events.protected voidonBeforeDelete(Object entity) Override this method if you are interested in beforeDelete events.protected voidonBeforeLinkSave(Object parent, Object linked) Override this method if you are interested in beforeLinkSave events.protected voidonBeforeSave(Object entity) Override this method if you are interested in beforeSave events.setValidators(Map<String, Collection<Validator>> validators) Assign a Map ofValidators that are assigned to the variousRepositoryEvents.Methods inherited from class org.springframework.data.rest.core.event.AbstractRepositoryEventListener
onAfterLinkDelete, onApplicationEvent, onBeforeLinkDeleteMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Constructor Details
-
ValidatingRepositoryEventListener
public ValidatingRepositoryEventListener(ObjectFactory<PersistentEntities> persistentEntitiesFactory) Creates a newValidatingRepositoryEventListenerusing the given repositories.- Parameters:
persistentEntitiesFactory- must not be null.
-
-
Method Details
-
setValidators
public ValidatingRepositoryEventListener setValidators(Map<String, Collection<Validator>> validators) Assign a Map ofValidators that are assigned to the variousRepositoryEvents.- Parameters:
validators- A Map of Validators to wire.- Returns:
-
addValidator
Add aValidatorthat 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:AbstractRepositoryEventListenerOverride this method if you are interested in beforeCreate events.- Overrides:
onBeforeCreatein classAbstractRepositoryEventListener<Object>- Parameters:
entity- The entity being created.
-
onAfterCreate
Description copied from class:AbstractRepositoryEventListenerOverride this method if you are interested in afterCreate events.- Overrides:
onAfterCreatein classAbstractRepositoryEventListener<Object>- Parameters:
entity- The entity that was created.
-
onBeforeSave
Description copied from class:AbstractRepositoryEventListenerOverride this method if you are interested in beforeSave events.- Overrides:
onBeforeSavein classAbstractRepositoryEventListener<Object>- Parameters:
entity- The entity being saved.
-
onAfterSave
Description copied from class:AbstractRepositoryEventListenerOverride this method if you are interested in afterSave events.- Overrides:
onAfterSavein classAbstractRepositoryEventListener<Object>- Parameters:
entity- The entity that was just saved.
-
onBeforeLinkSave
Description copied from class:AbstractRepositoryEventListenerOverride this method if you are interested in beforeLinkSave events.- Overrides:
onBeforeLinkSavein classAbstractRepositoryEventListener<Object>- Parameters:
parent- The parent entity to which the child object is linked.linked- The linked, child entity.
-
onAfterLinkSave
Description copied from class:AbstractRepositoryEventListenerOverride this method if you are interested in afterLinkSave events.- Overrides:
onAfterLinkSavein classAbstractRepositoryEventListener<Object>- Parameters:
parent- The parent entity to which the child object is linked.linked- The linked, child entity.
-
onBeforeDelete
Description copied from class:AbstractRepositoryEventListenerOverride this method if you are interested in beforeDelete events.- Overrides:
onBeforeDeletein classAbstractRepositoryEventListener<Object>- Parameters:
entity- The entity that is being deleted.
-
onAfterDelete
Description copied from class:AbstractRepositoryEventListenerOverride this method if you are interested in afterDelete events.- Overrides:
onAfterDeletein classAbstractRepositoryEventListener<Object>- Parameters:
entity- The entity that was just deleted.
-