Interface Registration
- All Known Implementing Classes:
AbstractWebsocketClient.PingRegistration, DefaultTracker, ProxyServer
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents a handle for a cancellable registration, such as a subscription, listener, or callback.
The Registration interface is widely used throughout Fluxzero to manage lifecycle-bound resources like
message consumers, handler tracking, interceptors, and more. Calling cancel() releases the associated resource.
Usage
Registration registration = tracker.start();
// Later
registration.cancel(); // Stops tracking
Combining multiple registrations
Themerge(Registration) method allows combining multiple registrations into a single handle.
Cancelling the combined registration will cancel both underlying registrations:
Registration r1 = trackerA.start();
Registration r2 = trackerB.start();
Registration combined = r1.merge(r2);
combined.cancel(); // Cancels both r1 and r2
No-op Registration
UsenoOp() to obtain a dummy Registration that performs no action when cancelled.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Cancels the resource or subscription associated with this registration.default Registrationmerge(Registration otherRegistration) Returns a newRegistrationthat cancels both this and the givenotherRegistration.static RegistrationnoOp()Returns a no-opRegistrationthat does nothing oncancel().
-
Method Details
-
noOp
Returns a no-opRegistrationthat does nothing oncancel(). -
cancel
void cancel()Cancels the resource or subscription associated with this registration.Calling this method should be idempotent and safe to invoke multiple times.
-
merge
Returns a newRegistrationthat cancels both this and the givenotherRegistration.This is useful when managing multiple resources together:
Registration combined = reg1.merge(reg2);- Parameters:
otherRegistration- another registration to combine with this one- Returns:
- a composite registration
-