Package ch.tocco.nice2.util.invokables
Class AbstractInvoker<S>
java.lang.Object
ch.tocco.nice2.util.invokables.AbstractInvoker<S>
- All Implemented Interfaces:
- Invoker
- Direct Known Subclasses:
- EmptyInvoker,- PredefinedAnswersInvoker,- RemoteContextInvoker,- UpdatePublishStatusContext.Invoker,- UriConversionEntityInterceptorContext.Invoker
An abstract implementation of invoker. Extending classes should only override
 
preInvoke() and postInvoke().
 This class takes care of all exception handling.- 
Field Summary
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionCombines `this` and the givenInvokerby calling `other` inside `this` invoker.static InvokerCreates a new invoker that is a combination of the given ones, where the first invoker in the list is the outer-most 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.protected abstract voidpostInvoke(S state, @Nullable Object result, @Nullable Throwable thrown) Called after the given invokable has been invoked.protected abstract SCalled before the given invokable is invoked.
- 
Constructor Details- 
AbstractInvokerpublic AbstractInvoker()
 
- 
- 
Method Details- 
invokeDescription copied from interface:InvokerInvokes the specifiedRunnable.
- 
invokeDescription copied from interface:InvokerInvokes the specifiedCallable.
- 
invokeRTEDescription copied from interface:InvokerInvokes the specifiedCallablenot expecting any checked exceptions.
- 
invokeDescription copied from interface:InvokerInvokes the specifiedCallableexpecting the specified exception.
- 
invokepublic <T,E1 extends Exception, T invokeE2 extends Exception> (Callable<T> callable, Class<E1> e1, Class<E2> e2) throws E1, E2 Description copied from interface:InvokerInvokes the specifiedCallableexpecting the specified exceptions.
- 
invokepublic <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 Description copied from interface:InvokerInvokes the specifiedCallableexpecting the specified exceptions.
- 
invokeDescription copied from interface:InvokerInvokes the specifiedFunctionwith the specified input.
- 
andThenDescription copied from interface:InvokerCombines `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 functionfrom(Invoker...)
- 
preInvokeCalled before the given invokable is invoked.- Returns:
- An optional state which will be passed to
         postInvoke().
 
- 
postInvokeprotected abstract void postInvoke(S state, @Nullable @Nullable Object result, @Nullable @Nullable Throwable thrown) Called after the given invokable has been invoked. This will be called in a finally block regardless of whether the invokable throw an exception or not. If the invokable threw an exception and this method throws again, the exception thrown will be added as suppressed exception to the exception originally thrown by the invokable.- Parameters:
- state- The state as returned previously by- preInvoke().
- result- The return value of the invokable or `null`.
- thrown- The exception thrown by the invokable or `null`.
- See Also:
 
- 
fromCreates a new invoker that is a combination of the given ones, where the first invoker in the list is the outer-most invoker. If the list is empty, theempty invokeris returned.- Parameters:
- invokers- the invokers to combine
- Returns:
- the combined invoker
 
 
-