Class HandlerRegistry.MergedHandlerRegistry

java.lang.Object
io.fluxzero.sdk.tracking.handling.HandlerRegistry.MergedHandlerRegistry
All Implemented Interfaces:
HandlerRegistry, HasLocalHandlers
Enclosing interface:
HandlerRegistry

public static class HandlerRegistry.MergedHandlerRegistry extends Object implements HandlerRegistry
Combines two HandlerRegistry instances into one.

Useful for layering or composing registries programmatically.

  • Field Details

  • Constructor Details

    • MergedHandlerRegistry

      public MergedHandlerRegistry()
  • Method Details

    • handle

      Description copied from interface: HandlerRegistry
      Attempts to handle the given message using local handlers.
      Specified by:
      handle in interface HandlerRegistry
      Parameters:
      message - the deserialized message to dispatch
      Returns:
      an optional future containing the result, or empty if no handler was found
    • handle

      public Optional<CompletableFuture<Object>> handle(DeserializingMessage message, boolean allowExternalPublication)
      Description copied from interface: HandlerRegistry
      Attempts to handle the message locally while controlling optional SDK-managed external publication.

      The default delegates to HandlerRegistry.handle(DeserializingMessage) because custom registries are assumed to invoke local handlers only. Registries that optionally mirror locally handled messages externally should honor allowExternalPublication.

      Specified by:
      handle in interface HandlerRegistry
      Parameters:
      message - the deserialized message to dispatch
      allowExternalPublication - whether SDK-managed mirroring may publish the message externally
      Returns:
      an optional future containing the result, or empty if no handler was found
    • canHandle

      public boolean canHandle(DeserializingMessage message)
      Description copied from interface: HandlerRegistry
      Returns whether this registry has a local handler that can process the given message.
      Specified by:
      canHandle in interface HandlerRegistry
      Parameters:
      message - the message to inspect
      Returns:
      true if a local handler can handle the message, false otherwise
    • registerHandler

      public io.fluxzero.common.Registration registerHandler(Object target)
      Description copied from interface: HasLocalHandlers
      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 like HandleQuery inside its class and the class is not annotated with TrackSelf, the handler is also considered to be local.

      Specified by:
      registerHandler in interface HasLocalHandlers
      Parameters:
      target - the object containing handler methods
      Returns:
      a Registration which can be used to unregister the handlers
    • hasLocalHandlers

      public boolean hasLocalHandlers()
      Description copied from interface: HasLocalHandlers
      Indicates whether any local handlers are currently registered for this gateway.
      Specified by:
      hasLocalHandlers in interface HasLocalHandlers
      Returns:
      true if local handlers are present, false otherwise
    • setSelfHandlerFilter

      public void setSelfHandlerFilter(io.fluxzero.common.handling.HandlerFilter selfHandlerFilter)
      Description copied from interface: HasLocalHandlers
      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.
      Specified by:
      setSelfHandlerFilter in interface HasLocalHandlers
      Parameters:
      selfHandlerFilter - a HandlerFilter to apply to registered handlers
    • registerHandler

      public io.fluxzero.common.Registration registerHandler(Object target, io.fluxzero.common.handling.HandlerFilter handlerFilter)
      Description copied from interface: HasLocalHandlers
      Registers a handler object, including only those methods that match the provided HandlerFilter.

      This method offers fine-grained control over which handler methods are registered, based on custom logic applied to method annotations and/or signatures.

      Specified by:
      registerHandler in interface HasLocalHandlers
      Parameters:
      target - the handler object containing annotated methods
      handlerFilter - the filter used to determine which methods should be registered
      Returns:
      a Registration which can be used to unregister the handlers