Interface HandlerFactory
- All Known Implementing Classes:
DefaultHandlerFactory, ModelCommitHandlerRegistry
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 TypeMethodDescriptionOptional<io.fluxzero.common.handling.Handler<DeserializingMessage>> createHandler(Object target, io.fluxzero.common.handling.HandlerFilter handlerFilter, List<HandlerInterceptor> extraInterceptors) Attempts to create a message handler for the giventargetobject.default List<?> trackingTargets(Object target, io.fluxzero.common.handling.HandlerFilter handlerFilter) Expands a registered target into the targets that should participate in tracking and consumer selection.
-
Method Details
-
trackingTargets
default List<?> trackingTargets(Object target, io.fluxzero.common.handling.HandlerFilter handlerFilter) Expands a registered target into the targets that should participate in tracking and consumer selection.Most handlers track the registered target itself. Handler vocabularies whose receiver differs from the incoming payload can expose the payload type here, ensuring that package- and class-scoped consumer configuration is resolved from the message being consumed.
- Parameters:
target- registered handler targethandlerFilter- filter used for this tracking message type- Returns:
- targets to assign to consumers
-
createHandler
Optional<io.fluxzero.common.handling.Handler<DeserializingMessage>> createHandler(Object target, io.fluxzero.common.handling.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.
-