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.

@FunctionalInterface public static interface EventPublicationInterceptor.ApplicationEventFactory
Callback interface for building an ApplicationEvent after a method invocation.
Since:
7.0.3
Author:
Dmitriy Kopylenko, Juergen Hoeller, Rick Evans
  • Method Details

    • onSuccess

      @Nullable ApplicationEvent onSuccess(MethodInvocation invocation, @Nullable Object returnValue)
      Build an ApplicationEvent for the given successful method invocation.

      This is the primary method to implement since there is no such default event. This may also return null for not publishing an event on success at all.

      Parameters:
      invocation - the successful method invocation
      returnValue - the value that the method returned, if any
      Returns:
      the event to publish, or null for none
    • onFailure

      default @Nullable ApplicationEvent onFailure(MethodInvocation invocation, Throwable failure)
      Build an ApplicationEvent for the given failed method invocation.

      The default implementation builds a common MethodFailureEvent. This can be overridden to build a custom event instead, or to return null for not publishing an event on failure at all.

      Parameters:
      invocation - the failed method invocation
      failure - the exception thrown from the method
      Returns:
      the event to publish, or null for none