Class ServiceLoaderUtil


  • public final class ServiceLoaderUtil
    extends java.lang.Object
    This class should be considered internal.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int MAX_BROKEN_SERVICES  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ServiceLoaderUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static <T> java.lang.Iterable<T> callServiceLoader​(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.Class<T> serviceType, java.lang.ClassLoader classLoader, boolean verbose)  
      (package private) static <T> java.util.stream.Stream<T> loadClassloaderServices​(java.lang.Class<T> serviceType, java.lang.invoke.MethodHandles.Lookup lookup, java.lang.ClassLoader classLoader, boolean verbose)  
      static <T> java.util.stream.Stream<T> loadServices​(java.lang.Class<T> serviceType, java.lang.invoke.MethodHandles.Lookup lookup)
      Retrieves the available services from the caller's classloader.
      static <T> java.util.stream.Stream<T> loadServices​(java.lang.Class<T> serviceType, java.lang.invoke.MethodHandles.Lookup lookup, boolean useTccl)
      Retrieves the available services from the caller's classloader and possibly the thread context classloader.
      (package private) static <T> java.util.stream.Stream<T> loadServices​(java.lang.Class<T> serviceType, java.lang.invoke.MethodHandles.Lookup lookup, boolean useTccl, boolean verbose)  
      • Methods inherited from class java.lang.Object

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

      • ServiceLoaderUtil

        private ServiceLoaderUtil()
    • Method Detail

      • loadServices

        public static <T> java.util.stream.Stream<T> loadServices​(java.lang.Class<T> serviceType,
                                                                  java.lang.invoke.MethodHandles.Lookup lookup)
        Retrieves the available services from the caller's classloader. Broken services will be ignored.
        Type Parameters:
        T - The service type.
        Parameters:
        serviceType - The class of the service.
        lookup - The calling class data.
        Returns:
        A stream of service instances.
      • loadServices

        public static <T> java.util.stream.Stream<T> loadServices​(java.lang.Class<T> serviceType,
                                                                  java.lang.invoke.MethodHandles.Lookup lookup,
                                                                  boolean useTccl)
        Retrieves the available services from the caller's classloader and possibly the thread context classloader. Broken services will be ignored.
        Type Parameters:
        T - The service type.
        Parameters:
        serviceType - The class of the service.
        lookup - The calling class data.
        useTccl - If true the thread context classloader will also be used.
        Returns:
        A stream of service instances.
      • loadServices

        static <T> java.util.stream.Stream<T> loadServices​(java.lang.Class<T> serviceType,
                                                           java.lang.invoke.MethodHandles.Lookup lookup,
                                                           boolean useTccl,
                                                           boolean verbose)
      • loadClassloaderServices

        static <T> java.util.stream.Stream<T> loadClassloaderServices​(java.lang.Class<T> serviceType,
                                                                      java.lang.invoke.MethodHandles.Lookup lookup,
                                                                      java.lang.ClassLoader classLoader,
                                                                      boolean verbose)
      • callServiceLoader

        static <T> java.lang.Iterable<T> callServiceLoader​(java.lang.invoke.MethodHandles.Lookup lookup,
                                                           java.lang.Class<T> serviceType,
                                                           java.lang.ClassLoader classLoader,
                                                           boolean verbose)