Class MutableHandler<M>
java.lang.Object
io.fluxzero.sdk.tracking.handling.MutableHandler<M>
- Type Parameters:
M- the message type this handler supports
A specialized
Handler that maintains and mutates an internal delegate instance.
This handler is designed for use cases where the state of the handler may evolve dynamically across message invocations. It is particularly suited for temporarily scoped objects (e.g. sagas, user sessions).
Behavior
When a handler method returns an instance of the handler’s target class, this instance is stored as the new delegate:Object result = method.invoke(target);
if (result instanceof MyHandler) {
target = result; // promote new version
}
If the method returns null and the method's return type matches the target class, the internal
target is cleared, and any registered delete callbacks are triggered.
Lifecycle Hooks
A delete callback can be registered usingonDelete(Runnable) to perform cleanup when
the handler deletes its state (i.e., returns null).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondefault io.fluxzero.common.api.tracking.ConsumerFilterdefault io.fluxzero.common.handling.HandlerMethod<M> getHandlerMethodOrNull(M arg0) default io.fluxzero.common.handling.HandlerMethodPlanner<M> default io.fluxzero.common.handling.HandlerMethodPlan<M> getHandlerMethodPlanOrNull(M arg0) Optional<io.fluxzero.common.handling.HandlerInvoker> getInvoker(M message) default io.fluxzero.common.handling.HandlerInvokergetInvokerOrNull(M arg0) Class<?> Creates a new target using its no-argument constructor, replaces the current target, and returns this handler.booleanisEmpty()Returns whether this handler currently has no target instance.io.fluxzero.common.RegistrationRegisters a callback for target deletion and returns a registration that removes the callback.default io.fluxzero.common.handling.Handler<M>
-
Constructor Details
-
MutableHandler
public MutableHandler()
-
-
Method Details
-
getInvoker
-
instantiateTarget
Creates a new target using its no-argument constructor, replaces the current target, and returns this handler. -
isEmpty
public boolean isEmpty()Returns whether this handler currently has no target instance. -
onDelete
Registers a callback for target deletion and returns a registration that removes the callback. -
getConsumerFilter
default io.fluxzero.common.api.tracking.ConsumerFilter getConsumerFilter() -
getTargetClass
Class<?> getTargetClass() -
getInvokerOrNull
-
getHandlerMethodOrNull
-
getHandlerMethodPlanOrNull
-
getHandlerMethodPlanner
-
or
-