Class Service


  • public final class Service
    extends java.lang.Object
    Utility class for locating and instantiating service providers.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object getProvider​(java.lang.String providerName)
      Attempts to load a service provider.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getProvider

        public static java.lang.Object getProvider​(java.lang.String providerName)
        Attempts to load a service provider.
        Parameters:
        providerName - The name of the provider to load. The method first looks for a system property with this name. The value of the property is expected to be the name of a class that implements the expected provider interface.

        If the system property does not exist, the method then attempts to load a resource with this name from the META-INF/services directory. The resource is expected to be a text file containing a single line that is the name of the provider class.

        Returns:
        The provider object (if any), or null if the provider cannot be found or loaded.