org.apache.logging.log4j.util

Class ServiceLoaderUtil



  • public final class ServiceLoaderUtil
    extends Object
    This class should be considered internal.
    • Method Detail

      • loadServices

        public static <T> Stream<T> loadServices(Class<T> serviceType,
                                                 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> Stream<T> loadServices(Class<T> serviceType,
                                                 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.

Copyright © 1999-2023 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.