Package ch.tocco.nice2.util.invokables
Interface Invoker
- All Known Implementing Classes:
AbstractInvoker,EmptyInvoker,PredefinedAnswersInvoker,RemoteContextInvoker,UpdatePublishStatusContext.Invoker,UriConversionEntityInterceptorContext.Invoker
public interface Invoker
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionCombines `this` and the givenInvokerby calling `other` inside `this` invoker.voidInvokes the specifiedRunnable.<T> TInvokes the specifiedCallable.<T,E1 extends Exception>
TInvokes the specifiedCallableexpecting the specified exception.Invokes the specifiedCallableexpecting the specified exceptions.Invokes the specifiedCallableexpecting the specified exceptions.<F,T> T Invokes the specifiedFunctionwith the specified input.<T> TInvokes the specifiedCallablenot expecting any checked exceptions.
-
Field Details
-
EMPTY
This invoker is simply executing the given `Runnable`s/`Callable`s doing nothing before or after the call.
-
-
Method Details
-
invoke
Invokes the specifiedRunnable.- Parameters:
runnable- TheRunnableto invoke.
-
invoke
Invokes the specifiedCallable. -
invokeRTE
Invokes the specifiedCallablenot expecting any checked exceptions.- Parameters:
callable- TheCallableto invoke.- Returns:
- The return value of the
Callable. - Throws:
UndeclaredThrowableException- If the callable threw a checked exception.
-
invoke
Invokes the specifiedCallableexpecting the specified exception.- Parameters:
callable- TheCallableto 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, T invokeE2 extends Exception> (Callable<T> callable, Class<E1> e1, Class<E2> e2) throws E1, E2 Invokes the specifiedCallableexpecting the specified exceptions.- Parameters:
callable- TheCallableto 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.E1E2
-
invoke
<T,E1 extends Exception, T invokeE2 extends Exception, E3 extends Exception> (Callable<T> callable, Class<E1> e1, Class<E2> e2, Class<E3> e3) throws E1, E2, E3 Invokes the specifiedCallableexpecting the specified exceptions.- Parameters:
callable- TheCallableto 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.E1E2E3
-
invoke
Invokes the specifiedFunctionwith the specified input.- Parameters:
function- TheFunctionto invoke.input- The input value.- Returns:
- The result of the function.
-
andThen
Combines `this` and the givenInvokerby 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 functionAbstractInvoker.from(Invoker...)
-