Interface HandlerInvoker
- All Known Implementing Classes:
DocumentHandlerDecorator.DocumentHandler.DocumentHandlerInvoker, HandlerInspector.MethodHandlerMatcher.MethodHandlerInvoker, HandlerInvoker.DelegatingHandlerInvoker, HandlerInvoker.SimpleInvoker, StatefulHandler.StatefulHandlerInvoker
public interface HandlerInvoker
Represents an invocable handler method.
A HandlerInvoker is typically resolved by a Handler for a specific message, and is responsible for
invoking the actual handler method, including any surrounding interceptors or decorators.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classAHandlerInvokerthat delegates all behavior to another instance.static final classA simple invoker backed by aCallable, typically used for test utilities or framework-internal logic. -
Method Summary
Modifier and TypeMethodDescriptiondefault HandlerInvokerandFinally(HandlerInvoker other) Composes this invoker with another to be invoked in afinallyblock.static HandlerInvokerWraps aCallablein aHandlerInvoker.booleanIndicates whether the handler method has a return value.<A extends Annotation>
ARetrieves a specific annotation from the handler method, if present.Class<?> The target class that contains the handler method.default Objectinvoke()Invokes the handler using the default result-combining strategy (returns the first result).invoke(BiFunction<Object, Object, Object> resultCombiner) Invokes the handler and combines results using the given combiner function.booleanIndicates whether this handler operates in passive mode (i.e., results will not be published).static Optional<HandlerInvoker> join(List<? extends HandlerInvoker> invokers) Joins a list of invokers into a single composite invoker.static HandlerInvokernoOp()Returns a no-op invoker that performs no action and returnsnull.static HandlerInvokerrun(ThrowingRunnable task) Wraps aThrowingRunnablein aHandlerInvoker.
-
Method Details
-
noOp
Returns a no-op invoker that performs no action and returnsnull. -
run
Wraps aThrowingRunnablein aHandlerInvoker.- Parameters:
task- the task to run- Returns:
- a
HandlerInvokerthat runs the given task
-
call
Wraps aCallablein aHandlerInvoker.- Parameters:
task- the task to call- Returns:
- a
HandlerInvokerthat invokes the given callable
-
join
Joins a list of invokers into a single composite invoker. The result of each invocation is combined using the provided combiner function.- Parameters:
invokers- a list of invokers to join- Returns:
- an optional containing the combined invoker, or empty if the list is empty
-
andFinally
Composes this invoker with another to be invoked in afinallyblock. The second invoker will always run, even if the first one fails.- Parameters:
other- the invoker to run after this one- Returns:
- a combined invoker with finalization behavior
-
getTargetClass
Class<?> getTargetClass()The target class that contains the handler method.- Returns:
- the declaring class of the handler
-
getMethod
Executable getMethod()- Returns:
- the executable method
-
getMethodAnnotation
Retrieves a specific annotation from the handler method, if present.- Type Parameters:
A- the annotation type- Returns:
- the annotation instance, or
nullif not found
-
expectResult
boolean expectResult()Indicates whether the handler method has a return value.This is based on the method's signature: if it returns
void, this returnsfalse; otherwise, it returnstrue.- Returns:
trueif the method returns a value;falseif it isvoid
-
isPassive
boolean isPassive()Indicates whether this handler operates in passive mode (i.e., results will not be published).- Returns:
trueif passive; otherwisefalse
-
invoke
Invokes the handler using the default result-combining strategy (returns the first result).- Returns:
- the result of the handler invocation
-
invoke
Invokes the handler and combines results using the given combiner function. Used when aggregating results from multiple invokers (e.g.join(List)).- Parameters:
resultCombiner- function to combine multiple results- Returns:
- the combined result
-