Class ServiceLoaders


  • public class ServiceLoaders
    extends Object
    Created by tchemit on 30/05/2018.
    Author:
    Tony Chemit - dev@tchemit.fr
    • Constructor Detail

      • ServiceLoaders

        public ServiceLoaders()
    • Method Detail

      • reload

        public static <S> ServiceLoader<S> reload​(Class<S> serviceType)
        Get service loader for given serviceType, applying a ServiceLoader.reload() before returns.
        Type Parameters:
        S - generic type of service to load
        Parameters:
        serviceType - type of service to load
        Returns:
        the service loader reloaded.
        Since:
        1.0.10
      • loadUniqueService

        public static <S> S loadUniqueService​(Class<S> serviceType)
        Load the unique implementation of the given serviceType.
        Type Parameters:
        S - generic type of service to load
        Parameters:
        serviceType - type of service to load
        Returns:
        the unique service found
        Throws:
        IllegalStateException - if could not find the servcie, or if there is more than one implementations found.
      • loadTypes

        public static <O> List<Class<O>> loadTypes​(Class<O> serviceType)
        Load of classes of the given serviceType using ServiceLoader mecanism, but without loading any of those services.
        Type Parameters:
        O - type of service to seek
        Parameters:
        serviceType - type of service to seek
        Returns:
        list of all implementation found via ServiceLoader mechanism for given type