Interface EventPublicationInterceptor.ApplicationEventFactory
- Enclosing class:
EventPublicationInterceptor
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Callback interface for building an
ApplicationEvent after a method invocation.- Since:
- 7.0.3
- Author:
- Dmitriy Kopylenko, Juergen Hoeller, Rick Evans
-
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable ApplicationEventonFailure(MethodInvocation invocation, Throwable failure) Build anApplicationEventfor the given failed method invocation.onSuccess(MethodInvocation invocation, @Nullable Object returnValue) Build anApplicationEventfor the given successful method invocation.
-
Method Details
-
onSuccess
Build anApplicationEventfor the given successful method invocation.This is the primary method to implement since there is no such default event. This may also return
nullfor not publishing an event on success at all.- Parameters:
invocation- the successful method invocationreturnValue- the value that the method returned, if any- Returns:
- the event to publish, or
nullfor none
-
onFailure
Build anApplicationEventfor the given failed method invocation.The default implementation builds a common
MethodFailureEvent. This can be overridden to build a custom event instead, or to returnnullfor not publishing an event on failure at all.- Parameters:
invocation- the failed method invocationfailure- the exception thrown from the method- Returns:
- the event to publish, or
nullfor none
-