Class DefaultHandlerRepository
java.lang.Object
io.fluxzero.sdk.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 ConstraintasConstraint(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 aHandlerRepositoryfor 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 aHandlerRepositoryfor 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 creatingSerializedDocumentobjects- Returns:
- a factory function that returns a suitable
HandlerRepositoryfor each handler class
-
findByAssociation
Description copied from interface:HandlerRepositoryFinds 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
@Associationin registered handler instances.- Specified by:
findByAssociationin 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:HandlerRepositoryRetrieves all currently stored handler instances.- Specified by:
getAllin interfaceHandlerRepository- Returns:
- a collection of all known handler entries
-
put
Description copied from interface:HandlerRepositoryPersists or updates the handler instance identified by the given ID.- Specified by:
putin 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:HandlerRepositoryRemoves the handler instance identified by the given ID from the repository.- Specified by:
deletein interfaceHandlerRepository- Parameters:
id- the identifier of the handler instance to delete- Returns:
- a future that completes when the deletion has finished
-