Class DefaultHandlerRepository

java.lang.Object
io.fluxcapacitor.javaclient.modeling.DefaultHandlerRepository
All Implemented Interfaces:
HandlerRepository

public class DefaultHandlerRepository extends Object implements HandlerRepository
Default implementation of HandlerRepository, backed by a DocumentStore.

This repository provides direct indexing and retrieval of @Stateful handlers, using values from fields and methods annotated with Association.

Timestamp information can optionally be derived from paths specified in the Stateful annotation on the handler class.

  • Constructor Details

  • Method Details

    • handlerRepositorySupplier

      public static Function<Class<?>,HandlerRepository> handlerRepositorySupplier(Supplier<DocumentStore> documentStore, DocumentSerializer documentSerializer)
      Returns a factory function that creates a HandlerRepository for a given handler type.

      If the handler type is annotated with @Stateful(commitInBatch = true), the returned repository will buffer updates and commit them as a batch using BatchingHandlerRepository.

      Parameters:
      documentStore - the underlying document store supplier
      documentSerializer - serializer used for creating SerializedDocument objects
      Returns:
      a factory function that returns a suitable HandlerRepository for each handler class
    • findByAssociation

      public Collection<? extends Entry<Object>> findByAssociation(Map<Object,String> associations)
      Description copied from interface: HandlerRepository
      Finds all handler instances that match the given set of associations.

      The association map typically represents values extracted from incoming messages (e.g., correlation keys) and will be matched against fields or methods annotated with @Association in registered handler instances.

      Specified by:
      findByAssociation in interface HandlerRepository
      Parameters:
      associations - a map of association values, where the key is the value to match and the value is the corresponding property name or path (e.g. foo/bar/name) in the handler
      Returns:
      a collection of entries representing matching handler instances
    • asConstraint

      protected Constraint asConstraint(Map<Object,String> associations)
    • getAll

      public Collection<? extends Entry<?>> getAll()
      Description copied from interface: HandlerRepository
      Retrieves all currently stored handler instances.
      Specified by:
      getAll in interface HandlerRepository
      Returns:
      a collection of all known handler entries
    • put

      public CompletableFuture<?> put(Object id, Object value)
      Description copied from interface: HandlerRepository
      Persists or updates the handler instance identified by the given ID.
      Specified by:
      put in interface HandlerRepository
      Parameters:
      id - the unique identifier for the handler instance
      value - the handler instance to persist
      Returns:
      a future that completes when the operation has finished
    • delete

      public CompletableFuture<?> delete(Object id)
      Description copied from interface: HandlerRepository
      Removes the handler instance identified by the given ID from the repository.
      Specified by:
      delete in interface HandlerRepository
      Parameters:
      id - the identifier of the handler instance to delete
      Returns:
      a future that completes when the deletion has finished