Class MockReloadableService<T>

Type Parameters:
T - type of component
All Implemented Interfaces:
Component, DestructableComponent, IdentifiableComponent, IdentifiedComponent, InitializableComponent, UnmodifiableComponent, ReloadableService<T>

public class MockReloadableService<T> extends AbstractReloadableService<T>
Utility class for wrapping a serviceable component in a dummy reloadable service.
  • Field Details

  • Constructor Details

    • MockReloadableService

      public MockReloadableService(@Nullable T what)
      Constructor.
      Parameters:
      what - component
  • Method Details

    • getServiceableComponent

      @Nonnull public ServiceableComponent<T> getServiceableComponent()
      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

      Returns:
      the component, if appropriate.
    • shouldReload

      protected boolean shouldReload()
      Called by the AbstractReloadableService<T>.ServiceReloadTask to determine if the service should be reloaded.

      No lock is held when this method is called, so any locking needed should be handled internally.

      Specified by:
      shouldReload in class AbstractReloadableService<T>
      Returns:
      true iff the service should be reloaded