Interface HandlerFactory
- All Known Implementing Classes:
DefaultHandlerFactory
public interface HandlerFactory
Factory interface for creating
Handler instances that process DeserializingMessages.
A HandlerFactory is responsible for:
- Inspecting the target object for handler methods (e.g.
@HandleCommand,@HandleEvent, etc.) - Applying the provided
HandlerFilterto include or exclude individual methods - Wrapping the invocation logic with any additional
HandlerInterceptors - Returning a fully prepared
Handlerinstance 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 giventargetobject.
-
Method Details
-
createHandler
Optional<Handler<DeserializingMessage>> createHandler(Object target, HandlerFilter handlerFilter, List<HandlerInterceptor> extraInterceptors) Attempts to create a message handler for the giventargetobject.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 newHandlerinstance is constructed to wrap them.This is a central mechanism in Fluxzero used to support:
- Tracking handlers for stateful components
- Mutable, dynamic, or self-handling types
- In-memory
@LocalHandlers
- 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 additionalHandlerInterceptors to apply around message dispatch. These can be used to customize behavior with logging, retry logic, etc.- Returns:
- An
Optionalcontaining aHandlerif any suitable methods were found; otherwise, an emptyOptional.
-