Class SupplierBackedReloadableService<T>

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.service.SupplierBackedReloadableService<T>
Type Parameters:
T - component type
All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, ReloadableService<T>

public class SupplierBackedReloadableService<T> extends AbstractInitializableComponent implements ReloadableService<T>
A "null" implementation of ReloadableService that obtains an instance of an object via a strategy and exposes it as though it were a component wrapped by a service by nulling the relevant methods and interfaces.
Since:
9.3.0
  • Field Details

    • componentSource

      @Nonnull private Supplier<T> componentSource
      The supplier of the component to expose.
  • Constructor Details

    • SupplierBackedReloadableService

      public SupplierBackedReloadableService(@Nonnull Supplier<T> supplier)
      Constructor.
      Parameters:
      supplier - source of component called when the component is requested
  • Method Details

    • getLastSuccessfulReloadInstant

      @Nullable public Instant getLastSuccessfulReloadInstant()
      Gets the time when the service was last successfully reloaded. Returns null if the service has never reloaded.
      Specified by:
      getLastSuccessfulReloadInstant in interface ReloadableService<T>
      Returns:
      time when the service was last successfully reloaded
    • getLastReloadAttemptInstant

      @Nullable public Instant getLastReloadAttemptInstant()
      Gets the time when the service last attempted to reload. If the reload was successful this time should match the time given by ReloadableService.getLastSuccessfulReloadInstant().
      Specified by:
      getLastReloadAttemptInstant in interface ReloadableService<T>
      Returns:
      time when the service last attempted to reload
    • getReloadFailureCause

      @Nullable public Throwable getReloadFailureCause()
      Gets the reason the last reload failed.
      Specified by:
      getReloadFailureCause in interface ReloadableService<T>
      Returns:
      reason the last reload failed or null if the last reload was successful
    • reload

      public void reload()
      Reloads the configuration of the service. Whether internal state is maintained between reloads is implementation dependent.
      Specified by:
      reload in interface ReloadableService<T>
    • getServiceableComponent

      @Nonnull public ServiceableComponent<T> getServiceableComponent() throws ServiceException
      Get the serviceable component that this service supports. If the component hasn't been successfully loaded yet or if this service does not support a ServiceableComponent, a ServiceException is raised.

      On a non-null value, the returned component will be pinned and MUST be closed. This can be done by exploiting the fact that a ServiceableComponent implements AutoCloseable

      Specified by:
      getServiceableComponent in interface ReloadableService<T>
      Returns:
      the component, if appropriate.
      Throws:
      ServiceException - if the component is not available