Interface ServiceChangeEvent<T>

Type Parameters:
T - the service type
All Superinterfaces:
AsyncEvent, Event, RegistryEvent<T>

public interface ServiceChangeEvent<T> extends RegistryEvent<T>
Indicates the prioritised provider for a specific service changed. This happens whenever a new registration is added with a higher priority than the existing highest priority registration, or the highest priority registration was unregistered.

This event has a unique specification in that it guarantees a happens-before relationship for service changes. That is, if the provider changes from A to B to C, the event for the service change from A to B will happen before the event for that from B to C. This means it is acceptable to use this event to track changes in the current highest priority provider. However, it may be preferable to instead call Registry.getProvider(Class) each the provider is required.
Author:
A248
  • Method Details

    • getPrevious

      Optional<Registration<T>> getPrevious()
      Gets the previous highest priority registration.
      If there was no previous registration when the updated registration was registered, the optional will be empty.
      Returns:
      the previous registration, or an empty optional if there was none
    • getUpdated

      Optional<Registration<T>> getUpdated()
      Gets the updated highest priority registration.
      If the current highest priority registration was unregistered and there is no other registration for the same service, the optional will be empty.
      Returns:
      the updated registration, or an empty optional if there is none