Class DefaultHandlerRepository
java.lang.Object
io.fluxcapacitor.javaclient.modeling.DefaultHandlerRepository
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionDefaultHandlerRepository
(DocumentStore documentStore, String collection, Class<?> type, Stateful annotation) -
Method Summary
Modifier and TypeMethodDescriptionprotected Constraint
asConstraint
(Map<Object, String> associations) Removes the handler instance identified by the given ID from the repository.Collection
<? extends Entry<Object>> findByAssociation
(Map<Object, String> associations) Finds all handler instances that match the given set of associations.Collection
<? extends Entry<?>> getAll()
Retrieves all currently stored handler instances.static Function
<Class<?>, HandlerRepository> handlerRepositorySupplier
(Supplier<DocumentStore> documentStore, DocumentSerializer documentSerializer) Returns a factory function that creates aHandlerRepository
for a given handler type.Persists or updates the handler instance identified by the given ID.
-
Constructor Details
-
DefaultHandlerRepository
public DefaultHandlerRepository(DocumentStore documentStore, String collection, Class<?> type, Stateful annotation)
-
-
Method Details
-
handlerRepositorySupplier
public static Function<Class<?>,HandlerRepository> handlerRepositorySupplier(Supplier<DocumentStore> documentStore, DocumentSerializer documentSerializer) Returns a factory function that creates aHandlerRepository
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 usingBatchingHandlerRepository
.- Parameters:
documentStore
- the underlying document store supplierdocumentSerializer
- serializer used for creatingSerializedDocument
objects- Returns:
- a factory function that returns a suitable
HandlerRepository
for each handler class
-
findByAssociation
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 interfaceHandlerRepository
- 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
-
getAll
Description copied from interface:HandlerRepository
Retrieves all currently stored handler instances.- Specified by:
getAll
in interfaceHandlerRepository
- Returns:
- a collection of all known handler entries
-
put
Description copied from interface:HandlerRepository
Persists or updates the handler instance identified by the given ID.- Specified by:
put
in interfaceHandlerRepository
- Parameters:
id
- the unique identifier for the handler instancevalue
- the handler instance to persist- Returns:
- a future that completes when the operation has finished
-
delete
Description copied from interface:HandlerRepository
Removes the handler instance identified by the given ID from the repository.- Specified by:
delete
in interfaceHandlerRepository
- Parameters:
id
- the identifier of the handler instance to delete- Returns:
- a future that completes when the deletion has finished
-