Events
Spring Data ArangoDB includes several ApplicationEvent events that your application can respond to by registering subclasses of AbstractArangoEventListener in the ApplicationContext.
The following callback methods are present in AbstractArangoEventListener:
onAfterLoad: Called inArangoTemplate#findandArangoTemplate#queryafter the object is loaded from the database.onBeforeSave: Called inArangoTemplate#insert/#update/#replacebefore the object is converted and send to the database.onAfterSave: Called inArangoTemplate#insert/#update/#replaceafter the object is send to the database.onBeforeDelete: Called inArangoTemplate#deletebefore the object is converted and send to the database.onAfterDelete: Called inArangoTemplate#deleteafter the object is deleted from the database.
Examples
package my.mapping.events;
public class BeforePersonSavedListener extends AbstractArangoEventListener<Person> {
@Override
public void onBeforeSave(BeforeSaveEvent<Person> event) {
// do some logging or data manipulation
}
}
To register the listener add @ComponentScan with the package of your listener to your configuration class.
@Configuration
@ComponentScan("my.mapping.events")
public class MyConfiguration implements ArangoConfiguration {
...