Interface HasLocalHandlers
- All Known Subinterfaces:
CommandGateway
,ErrorGateway
,EventGateway
,EventStore
,GenericGateway
,HandlerRegistry
,MetricsGateway
,QueryGateway
,WebRequestGateway
- All Known Implementing Classes:
DefaultCommandGateway
,DefaultDocumentStore
,DefaultErrorGateway
,DefaultEventGateway
,DefaultEventStore
,DefaultGenericGateway
,DefaultMessageScheduler
,DefaultMetricsGateway
,DefaultQueryGateway
,DefaultWebRequestGateway
,HandlerRegistry.MergedHandlerRegistry
,HandlerRegistry.NoOpHandlerRegistry
,LocalDocumentHandlerRegistry
,LocalHandlerRegistry
Gateways that implement this interface can invoke message handlers directly in-memory, without involving the Flux platform. This is useful for scenarios where local responsiveness is critical or when the message is intended only for the current application.
Local handler registration is typically used for commands, queries, events, and other messages where in-process
handling is desired. Handlers are registered per-target object, and can be selectively filtered using a
HandlerFilter
.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicates whether any local handlers are currently registered for this gateway.default Registration
registerHandler
(Object target) Registers the given handler object and includes only the methods that are annotated with a recognized handler annotation (e.g.,@HandleCommand
,@HandleQuery
, etc.).registerHandler
(Object target, HandlerFilter handlerFilter) Registers a handler object, including only those methods that match the providedHandlerFilter
.void
setSelfHandlerFilter
(HandlerFilter selfHandlerFilter) Sets a custom filter to control whether a handler method is considered a local handler for the current application.
-
Method Details
-
registerHandler
Registers the given handler object and includes only the methods that are annotated with a recognized handler annotation (e.g.,@HandleCommand
,@HandleQuery
, etc.).This method uses
LocalHandler
to determine which methods to include. If a payload has an annotated handler likeHandleQuery
inside its class and the class is not annotated withTrackSelf
, the handler is also considered to be local.- Parameters:
target
- the object containing handler methods- Returns:
- a
Registration
which can be used to unregister the handlers
-
hasLocalHandlers
boolean hasLocalHandlers()Indicates whether any local handlers are currently registered for this gateway.- Returns:
true
if local handlers are present,false
otherwise
-
setSelfHandlerFilter
Sets a custom filter to control whether a handler method is considered a local handler for the current application. This is typically used internally to ensure that handlers are associated with the correct application or component.- Parameters:
selfHandlerFilter
- aHandlerFilter
to apply to registered handlers
-
registerHandler
Registers a handler object, including only those methods that match the providedHandlerFilter
.This method offers fine-grained control over which handler methods are registered, based on custom logic applied to method annotations and/or signatures.
- Parameters:
target
- the handler object containing annotated methodshandlerFilter
- the filter used to determine which methods should be registered- Returns:
- a
Registration
which can be used to unregister the handlers
-