T
- Entity type used to detect callbacks
to invoke via their generic type signature.public interface EntityCallback<T>
EntityCallback
Multiple entity callbacks are invoked sequentially with the result of the previous callback. Callbacks are unordered
by default. It is possible to define the order in which listeners for a certain domain type are to be invoked. To do
so, add Spring's common @Order
annotation or implement
Ordered
.
While it is possible for a EntityCallback
to declare that it throws arbitrary exception types, any checked
exceptions thrown from a EntityCallback
are wrapped in an
UndeclaredThrowableException
since the callback mechanism can
only handle runtime exceptions. Entity callback processing is stopped on the EntityCallback
that raised an
exception and the caused exception is propagated to the caller.
An EntityCallback
can generically declare the domain type that it is able to process by specifying the
generic type parameter <T>
. When registered with a Spring
ApplicationContext
, callbacks are filtered accordingly, with the callback getting
invoked for assignable domain objects only.
Typically, entity callbacks are invoked after publishing events
.
EntityCallback
Interfaces
A EntityCallback
interface needs to define a callback method accepting an object of the parameterized type as
its first argument followed by additional optional arguments.
public interface BeforeSaveCallback<T> extends EntityCallback<T> { T onBeforeSave(T entity, String collection); }
Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.