Class ServiceProviderHandler<T>

java.lang.Object
org.jppf.utils.ServiceProviderHandler<T>
Type Parameters:
T - the type of the SPI interface.

public class ServiceProviderHandler<T> extends Object
A utility class that handles a SPI mechanism. It loads all implementations of a service provider interface found in the classpath and provides access to them.
Author:
Laurent Cohen
  • Field Details

    • inf

      protected final Class<T> inf
      The interface to handle.
    • providers

      protected final List<T> providers
      The list of provider instances.
    • classLoader

      protected final ClassLoader classLoader
      The class loader used to lookup the service implementations.
  • Constructor Details

    • ServiceProviderHandler

      public ServiceProviderHandler(Class<T> inf)
      Parameters:
      inf - the service interface to handle.
    • ServiceProviderHandler

      public ServiceProviderHandler(Class<T> inf, ClassLoader classLoader)
      Parameters:
      inf - the service interface to handle.
      classLoader - the class loader used to lookup the service implementations.
  • Method Details

    • addProvider

      public void addProvider(T provider)
      Add a providers to the list of providers.
      Parameters:
      provider - the provider to add.
    • removeProvider

      public void removeProvider(T provider)
      Remove a listener from the list of providers.
      Parameters:
      provider - the provider to remove.
    • removeAllProviders

      public void removeAllProviders()
      Remove all providers from the list of providers.
    • getProviders

      public List<T> getProviders()
      Get all the rpoviders loaded by htis handler.
      Returns:
      a List of provider implementations.
    • loadProviders

      public void loadProviders()
      Load all provider instances found in the class path via a service definition.