Interface Invoker

All Known Implementing Classes:
AbstractInvoker, EmptyInvoker, PredefinedAnswersInvoker, RemoteContextInvoker, UpdatePublishStatusContext.Invoker, UriConversionEntityInterceptorContext.Invoker

public interface Invoker
  • Field Details

    • EMPTY

      static final Invoker EMPTY
      This invoker is simply executing the given `Runnable`s/`Callable`s doing nothing before or after the call.
  • Method Details

    • invoke

      void invoke(Runnable runnable)
      Invokes the specified Runnable.
      Parameters:
      runnable - The Runnable to invoke.
    • invoke

      <T> T invoke(Callable<T> callable) throws Exception
      Invokes the specified Callable.
      Parameters:
      callable - The Callable to invoke.
      Returns:
      The return value of the Callable.
      Throws:
      Exception - If the callable throws.
    • invokeRTE

      <T> T invokeRTE(Callable<T> callable)
      Invokes the specified Callable not expecting any checked exceptions.
      Parameters:
      callable - The Callable to invoke.
      Returns:
      The return value of the Callable.
      Throws:
      UndeclaredThrowableException - If the callable threw a checked exception.
    • invoke

      <T, E1 extends Exception> T invoke(Callable<T> callable, Class<E1> e1) throws E1
      Invokes the specified Callable expecting the specified exception.
      Parameters:
      callable - The Callable to invoke.
      e1 - The exception to expect.
      Returns:
      The return value of the Callable.
      Throws:
      UndeclaredThrowableException - If the callable threw an unexpected checked exception.
      E1
    • invoke

      <T, E1 extends Exception, E2 extends Exception> T invoke(Callable<T> callable, Class<E1> e1, Class<E2> e2) throws E1, E2
      Invokes the specified Callable expecting the specified exceptions.
      Parameters:
      callable - The Callable to invoke.
      e1 - The first exception to expect.
      e2 - The second exception to expect.
      Returns:
      The return value of the Callable.
      Throws:
      UndeclaredThrowableException - If the callable threw an unexpected checked exception.
      E1
      E2
    • invoke

      <T, E1 extends Exception, E2 extends Exception, E3 extends Exception> T invoke(Callable<T> callable, Class<E1> e1, Class<E2> e2, Class<E3> e3) throws E1, E2, E3
      Invokes the specified Callable expecting the specified exceptions.
      Parameters:
      callable - The Callable to invoke.
      e1 - The first exception to expect.
      e2 - The second exception to expect.
      e3 - The third exception to expect.
      Returns:
      The return value of the Callable.
      Throws:
      UndeclaredThrowableException - If the callable threw an unexpected checked exception.
      E1
      E2
      E3
    • invoke

      <F, T> T invoke(Function<F,T> function, F input)
      Invokes the specified Function with the specified input.
      Parameters:
      function - The Function to invoke.
      input - The input value.
      Returns:
      The result of the function.
    • andThen

      Invoker andThen(Invoker other)
      Combines `this` and the given Invoker by calling `other` inside `this` invoker. Thus, ```java SecurityManager sm = ... BusinessUnitManager bm = ... sm.privileged().andThen(bm.withBusinessUnit("m2")).invoke(new MyCallable...) ``` is equivalent to ```java sm.privileged().invoke(new Callable { public T call() throws Exception { bm.withBusinessUnit("m2").invoke(new MyCallable { }) } } ``` Which will both invoke `MyCallable` inside the BU-Invoker, which in turn is invoked within the Security-Manager-Invoker. This is to avoid too deep nesting of anonymous classes. The former variant takes also care of exception propagation, when the inner invoker expects different throwables to be thrown. You can also create an invoker from a list using the utility function AbstractInvoker.from(Invoker...)