Class ModelCommitHandlerRegistry
- All Implemented Interfaces:
HandlerFactory, HandlerRegistry, HasLocalHandlers, AutoCloseable
This type registers models and delegates application-bound definition lookup to MutationPlan. It owns no
evaluation, commit, retry, batching or completion state; every invocation delegates to the single
ModelPipeline lifecycle.
-
Nested Class Summary
Nested classes/interfaces inherited from interface HandlerRegistry
HandlerRegistry.MergedHandlerRegistry, HandlerRegistry.NoOpHandlerRegistry -
Constructor Summary
ConstructorsConstructorDescriptionModelCommitHandlerRegistry(DefaultModelRepository repository, EventStoreClient eventStoreClient, Serializer serializer, Serializer snapshotSerializer, DocumentSerializer documentSerializer, DispatchInterceptor eventDispatchInterceptor, String source, List<io.fluxzero.common.handling.ParameterResolver<? super DeserializingMessage>> parameterResolvers, HandlerDecorator handlerDecorator, io.fluxzero.common.api.modeling.ModelConflictPolicy conflictPolicy, ModelConflictResolver conflictResolver, int maxConflictRetries, AutomaticModelHandling automaticHandling, GraphProjectionCompletion graphProjectionCompletion) Creates the automatic model registration facade and its single execution pipeline. -
Method Summary
Modifier and TypeMethodDescriptionapplyStoredEvent(Message event) Replays one already accepted event without command assertions or interception.assertAndApply(Message update) Executes one explicit update through the model pipeline.assertAndApply(Message update, String modelId, Class<?> modelType) Executes one explicit update against the selected persisted model.assertAndApplyAll(List<Message> updates) Executes independent explicit updates with shared transport batching.assertLegal(Message update) Runs interceptors and immediate assertions without applying or committing.booleancanHandle(DeserializingMessage message) Returns whether this registry has a local handler that can process the given message.booleancanSkipLocalHandling(io.fluxzero.common.MessageType messageType, Class<?> payloadType) Conservatively reports whether local handling can be skipped without first materializing a message.voidclose()Optional<io.fluxzero.common.handling.Handler<DeserializingMessage>> createHandler(Object target, io.fluxzero.common.handling.HandlerFilter handlerFilter, List<HandlerInterceptor> extraInterceptors) Attempts to create a message handler for the giventargetobject.handle(DeserializingMessage message) Attempts to handle the given message using local handlers.booleanIndicates whether any local handlers are currently registered for this gateway.Returns registered or structurally referenced concrete model types.migratePublishedEvent(Message event, long eventIndex) Applies one existing globally published event without republishing it.Returns the model types registered as handlers in this application.io.fluxzero.common.RegistrationregisterHandler(Object target, io.fluxzero.common.handling.HandlerFilter handlerFilter) Registers a handler object, including only those methods that match the providedHandlerFilter.io.fluxzero.common.RegistrationregisterMigrationTypes(Collection<Class<?>> modelTypes) Registers Model definitions for migration without enabling command tracking or Graph projections.Returns the repository shared by automatic handling and public model loads.voidsetSelfHandlerFilter(io.fluxzero.common.handling.HandlerFilter selfHandlerFilter) Sets a custom filter to control whether a handler method is considered a local handler for the current application.List<?> trackingTargets(Object target, io.fluxzero.common.handling.HandlerFilter handlerFilter) Expands a registered target into the targets that should participate in tracking and consumer selection.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HandlerRegistry
andThen, handleLocal, handleResult, handleResult, orThenMethods inherited from interface HasLocalHandlers
registerHandler
-
Constructor Details
-
ModelCommitHandlerRegistry
public ModelCommitHandlerRegistry(DefaultModelRepository repository, EventStoreClient eventStoreClient, Serializer serializer, Serializer snapshotSerializer, DocumentSerializer documentSerializer, DispatchInterceptor eventDispatchInterceptor, String source, List<io.fluxzero.common.handling.ParameterResolver<? super DeserializingMessage>> parameterResolvers, HandlerDecorator handlerDecorator, io.fluxzero.common.api.modeling.ModelConflictPolicy conflictPolicy, ModelConflictResolver conflictResolver, int maxConflictRetries, AutomaticModelHandling automaticHandling, GraphProjectionCompletion graphProjectionCompletion) Creates the automatic model registration facade and its single execution pipeline.
-
-
Method Details
-
repository
Returns the repository shared by automatic handling and public model loads. -
registeredModelTypes
-
knownModelTypes
-
registerMigrationTypes
Registers Model definitions for migration without enabling command tracking or Graph projections. -
assertAndApply
Executes one explicit update through the model pipeline. -
assertAndApply
Executes one explicit update against the selected persisted model. -
assertAndApplyAll
Executes independent explicit updates with shared transport batching. -
assertLegal
Runs interceptors and immediate assertions without applying or committing. -
applyStoredEvent
Replays one already accepted event without command assertions or interception. -
migratePublishedEvent
Applies one existing globally published event without republishing it. -
handle
Description copied from interface:HandlerRegistryAttempts to handle the given message using local handlers.- Specified by:
handlein interfaceHandlerRegistry- Parameters:
message- the deserialized message to dispatch- Returns:
- an optional future containing the result, or empty if no handler was found
-
canHandle
Description copied from interface:HandlerRegistryReturns whether this registry has a local handler that can process the given message.- Specified by:
canHandlein interfaceHandlerRegistry- Parameters:
message- the message to inspect- Returns:
trueif a local handler can handle the message,falseotherwise
-
registerHandler
public io.fluxzero.common.Registration registerHandler(Object target, io.fluxzero.common.handling.HandlerFilter handlerFilter) Description copied from interface:HasLocalHandlersRegisters a handler object, including only those methods that match the providedHandlerFilter.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:
registerHandlerin interfaceHasLocalHandlers- Parameters:
target- the handler object containing annotated methodshandlerFilter- the filter used to determine which methods should be registered- Returns:
- a
Registrationwhich can be used to unregister the handlers
-
trackingTargets
public List<?> trackingTargets(Object target, io.fluxzero.common.handling.HandlerFilter handlerFilter) Description copied from interface:HandlerFactoryExpands a registered target into the targets that should participate in tracking and consumer selection.Most handlers track the registered target itself. Handler vocabularies whose receiver differs from the incoming payload can expose the payload type here, ensuring that package- and class-scoped consumer configuration is resolved from the message being consumed.
- Specified by:
trackingTargetsin interfaceHandlerFactory- Parameters:
target- registered handler targethandlerFilter- filter used for this tracking message type- Returns:
- targets to assign to consumers
-
createHandler
public Optional<io.fluxzero.common.handling.Handler<DeserializingMessage>> createHandler(Object target, io.fluxzero.common.handling.HandlerFilter handlerFilter, List<HandlerInterceptor> extraInterceptors) Description copied from interface:HandlerFactoryAttempts to create a message handler for the giventargetobject.This method analyzes the given object (or class) to discover message-handling methods (e.g.
@HandleCommand,@HandleQuery,@HandleEvent, etc.) that match the providedHandlerFilter. If any matching handler methods are found, a newHandlerinstance is constructed to wrap them.This is a central mechanism in Fluxzero used to support:
- Tracking handlers for stateful components
- Mutable, dynamic, or self-handling types
- In-memory
@LocalHandlers
- Specified by:
createHandlerin interfaceHandlerFactory- Parameters:
target- The handler target object or class. Can be a class (e.g.MyHandler.class) or an instantiated object.handlerFilter- A filter to determine which methods are valid handler methods. Only methods that pass this filter are included.extraInterceptors- A list of additionalHandlerInterceptors to apply around message dispatch. These can be used to customize behavior with logging, retry logic, etc.- Returns:
- An
Optionalcontaining aHandlerif any suitable methods were found; otherwise, an emptyOptional.
-
hasLocalHandlers
public boolean hasLocalHandlers()Description copied from interface:HasLocalHandlersIndicates whether any local handlers are currently registered for this gateway.- Specified by:
hasLocalHandlersin interfaceHasLocalHandlers- Returns:
trueif local handlers are present,falseotherwise
-
canSkipLocalHandling
public boolean canSkipLocalHandling(io.fluxzero.common.MessageType messageType, Class<?> payloadType) Description copied from interface:HandlerRegistryConservatively reports whether local handling can be skipped without first materializing a message.Custom registries default to
false. Returningtrueis an explicit promise that invoking this registry cannot produce a local result for the supplied message shape.- Specified by:
canSkipLocalHandlingin interfaceHandlerRegistry- Parameters:
messageType- the message typepayloadType- the runtime payload type- Returns:
trueonly when local handling can safely be skipped
-
setSelfHandlerFilter
public void setSelfHandlerFilter(io.fluxzero.common.handling.HandlerFilter selfHandlerFilter) Description copied from interface:HasLocalHandlersSets 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:
setSelfHandlerFilterin interfaceHasLocalHandlers- Parameters:
selfHandlerFilter- aHandlerFilterto apply to registered handlers
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-