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
-
Method Summary
Modifier and TypeMethodDescriptionCombines `this` and the givenInvoker
by calling `other` inside `this` invoker.void
Invokes the specifiedRunnable
.<T> T
Invokes the specifiedCallable
.<T,
E1 extends Exception>
TInvokes the specifiedCallable
expecting the specified exception.Invokes the specifiedCallable
expecting the specified exceptions.Invokes the specifiedCallable
expecting the specified exceptions.<F,
T> T Invokes the specifiedFunction
with the specified input.<T> T
Invokes the specifiedCallable
not 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
- TheRunnable
to invoke.
-
invoke
Invokes the specifiedCallable
. -
invokeRTE
Invokes the specifiedCallable
not expecting any checked exceptions.- Parameters:
callable
- TheCallable
to invoke.- Returns:
- The return value of the
Callable
. - Throws:
UndeclaredThrowableException
- If the callable threw a checked exception.
-
invoke
Invokes the specifiedCallable
expecting the specified exception.- Parameters:
callable
- TheCallable
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, T invokeE2 extends Exception> (Callable<T> callable, Class<E1> e1, Class<E2> e2) throws E1, E2 Invokes the specifiedCallable
expecting the specified exceptions.- Parameters:
callable
- TheCallable
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, 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 specifiedCallable
expecting the specified exceptions.- Parameters:
callable
- TheCallable
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
Invokes the specifiedFunction
with the specified input.- Parameters:
function
- TheFunction
to invoke.input
- The input value.- Returns:
- The result of the function.
-
andThen
Combines `this` and the givenInvoker
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 functionAbstractInvoker.from(Invoker...)
-