Class DefaultHandlerFactory

java.lang.Object
io.fluxcapacitor.javaclient.tracking.handling.DefaultHandlerFactory
All Implemented Interfaces:
HandlerFactory

public class DefaultHandlerFactory extends Object implements HandlerFactory
Default implementation of the HandlerFactory for creating message handlers based on reflection.

This factory supports a wide range of handler types including:

  • Simple class-based handlers (e.g., annotated with @HandleCommand, @HandleQuery, etc.)
  • Stateful handlers — persisted and associated via Association
  • SocketEndpoint handlers — WebSocket-based interaction handlers
  • TrackSelf annotated classes — handlers for self-tracking message types

Customization

The factory is configured with the following pluggable components:
  • A MessageType indicating the type of messages it supports (e.g., COMMAND, QUERY)
  • A HandlerDecorator used to wrap all created handlers with additional behavior
  • A list of ParameterResolvers to inject method parameters during handler invocation
  • A MessageFilter that determines whether a message is applicable to a handler method
  • A HandlerRepository supplier for managing persisted state in @Stateful handlers
  • A RepositoryProvider for shared caching of handler state (e.g., in SocketEndpointHandler)

Handler Resolution Process

The factory inspects the provided target object (or class) and applies the following logic:
  1. If the target is annotated with Stateful, a StatefulHandler is created
  2. If the target is annotated with SocketEndpoint, a SocketEndpointHandler is created
  3. If the target is annotated with TrackSelf, a handler is created with a filter ensuring messages are routed to matching payload types
  4. Otherwise, a default handler is created using DefaultHandler

Decorator Chaining

Any additional HandlerInterceptors passed at creation are composed with the default decorator and applied to the resulting handler.

Search-Specific Filtering

For MessageType.DOCUMENT and MessageType.CUSTOM, additional filters like HandleDocumentFilter and HandleCustomFilter are applied automatically.

This class is the main entry point for reflective handler generation in Flux Capacitor. It is used by both local and tracking-based handler registries to resolve method targets dynamically.

See Also: