Interface HandlerFactory
- All Known Implementing Classes:
DefaultHandlerFactory
public interface HandlerFactory
Factory interface for creating
Handler
instances that process DeserializingMessage
s.
A HandlerFactory
is responsible for:
- Inspecting the target object for handler methods (e.g.
@HandleCommand
,@HandleEvent
, etc.) - Applying the provided
HandlerFilter
to include or exclude individual methods - Wrapping the invocation logic with any additional
HandlerInterceptor
s - Returning a fully prepared
Handler
instance if any suitable methods are found
-
Method Summary
Modifier and TypeMethodDescriptioncreateHandler
(Object target, HandlerFilter handlerFilter, List<HandlerInterceptor> extraInterceptors) Attempts to create a message handler for the giventarget
object.
-
Method Details
-
createHandler
Optional<Handler<DeserializingMessage>> createHandler(Object target, HandlerFilter handlerFilter, List<HandlerInterceptor> extraInterceptors) Attempts to create a message handler for the giventarget
object.This method analyzes the given object (or class) to discover message-handling methods (e.g.
@HandleCommand
,@HandleQuery
,@HandleEvent
, etc.) that match the providedHandlerFilter
. If any matching handler methods are found, a newHandler
instance is constructed to wrap them.This is a central mechanism in Flux Capacitor used to support:
- Tracking handlers for stateful components
- Mutable, dynamic, or self-handling types
- In-memory
@LocalHandler
s
- Parameters:
target
- The handler target object or class. Can be a class (e.g.MyHandler.class
) or an instantiated object.handlerFilter
- A filter to determine which methods are valid handler methods. Only methods that pass this filter are included.extraInterceptors
- A list of additionalHandlerInterceptor
s to apply around message dispatch. These can be used to customize behavior with logging, retry logic, etc.- Returns:
- An
Optional
containing aHandler
if any suitable methods were found; otherwise, an emptyOptional
.
-