Package io.fluxcapacitor.common.handling
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 class
AHandlerInvoker
that delegates all behavior to another instance.static final class
A simple invoker backed by aCallable
, typically used for test utilities or framework-internal logic. -
Method Summary
Modifier and TypeMethodDescriptiondefault HandlerInvoker
andFinally
(HandlerInvoker other) Composes this invoker with another to be invoked in afinally
block.static HandlerInvoker
Wraps aCallable
in aHandlerInvoker
.boolean
Indicates 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 Object
invoke()
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.boolean
Indicates 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 HandlerInvoker
noOp()
Returns a no-op invoker that performs no action and returnsnull
.static HandlerInvoker
run
(ThrowingRunnable task) Wraps aThrowingRunnable
in aHandlerInvoker
.
-
Method Details
-
noOp
Returns a no-op invoker that performs no action and returnsnull
. -
run
Wraps aThrowingRunnable
in aHandlerInvoker
.- Parameters:
task
- the task to run- Returns:
- a
HandlerInvoker
that runs the given task
-
call
Wraps aCallable
in aHandlerInvoker
.- Parameters:
task
- the task to call- Returns:
- a
HandlerInvoker
that 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 afinally
block. 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
null
if 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:
true
if the method returns a value;false
if it isvoid
-
isPassive
boolean isPassive()Indicates whether this handler operates in passive mode (i.e., results will not be published).- Returns:
true
if 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
-