Class EnhancedServiceLoader

java.lang.Object
icu.easyj.core.loader.EnhancedServiceLoader

public abstract class EnhancedServiceLoader extends Object
The type Enhanced service loader. 注:从阿里的seata项目中复制过来的。
Author:
slievrly
  • Constructor Details

    • EnhancedServiceLoader

      public EnhancedServiceLoader()
  • Method Details

    • load

      public static <S> S load(Class<S> serviceClass, ClassLoader loader) throws EnhancedServiceNotFoundException
      Specify classLoader to load the service provider
      Type Parameters:
      S - the type of the service
      Parameters:
      serviceClass - the service class
      loader - the loader
      Returns:
      service the service
      Throws:
      EnhancedServiceNotFoundException - the enhanced service not found exception
    • load

      public static <S> S load(Class<S> serviceClass) throws EnhancedServiceNotFoundException
      load service provider
      Type Parameters:
      S - the type of the service
      Parameters:
      serviceClass - the service class
      Returns:
      service the service
      Throws:
      EnhancedServiceNotFoundException - the enhanced service not found exception
    • load

      public static <S> S load(Class<S> serviceClass, String activateName) throws EnhancedServiceNotFoundException
      load service provider
      Type Parameters:
      S - the type of the service
      Parameters:
      serviceClass - the service class
      activateName - the activate name
      Returns:
      service the service
      Throws:
      EnhancedServiceNotFoundException - the enhanced service not found exception
    • load

      public static <S> S load(Class<S> service, String activateName, ClassLoader loader) throws EnhancedServiceNotFoundException
      Specify classLoader to load the service provider
      Type Parameters:
      S - the type of the service
      Parameters:
      service - the service
      activateName - the activate name
      loader - the loader
      Returns:
      service the service
      Throws:
      EnhancedServiceNotFoundException - the enhanced service not found exception
    • load

      public static <S> S load(Class<S> serviceClass, String activateName, Object[] args) throws EnhancedServiceNotFoundException
      Load service
      Type Parameters:
      S - the type of the service
      Parameters:
      serviceClass - the service
      activateName - the activate name
      args - the args
      Returns:
      service the service
      Throws:
      EnhancedServiceNotFoundException - the enhanced service not found exception
    • load

      public static <S> S load(Class<S> serviceClass, String activateName, Class<?>[] argsType, Object[] args) throws EnhancedServiceNotFoundException
      Load service
      Type Parameters:
      S - the type of the service
      Parameters:
      serviceClass - the service
      activateName - the activate name
      argsType - the args type
      args - the args
      Returns:
      service the service
      Throws:
      EnhancedServiceNotFoundException - the enhanced service not found exception
    • load

      public static <S> S load(Class<S> serviceClass, String activateName, Class<?> argType, Object arg) throws EnhancedServiceNotFoundException
      Load service
      Type Parameters:
      S - the type of the service
      Parameters:
      serviceClass - the service
      activateName - the activate name
      argType - the only one arg type
      arg - the only one arg
      Returns:
      service the service
      Throws:
      EnhancedServiceNotFoundException - the enhanced service not found exception
    • loadAll

      @NonNull public static <S> List<S> loadAll(Class<S> serviceClass)
      get all implements
      Type Parameters:
      S - the type of the service
      Parameters:
      serviceClass - the service class
      Returns:
      list the service list
    • loadAll

      public static <S> List<S> loadAll(Class<S> serviceClass, Class<?>[] argsType, Object[] args)
      get all implements
      Type Parameters:
      S - the type of the service
      Parameters:
      serviceClass - the service
      argsType - the args type
      args - the args
      Returns:
      list the service list
    • loadBySupportNames

      public static <S> S loadBySupportNames(Class<S> serviceClass, @NonNull String... supportNames)
      Type Parameters:
      S - the type of the service
      Parameters:
      serviceClass - the service
      supportNames - the support service names
      Returns:
      service the service
    • loadBySupportNames

      public static <S> S loadBySupportNames(Class<S> serviceClass, Class<?>[] argsType, Object[] args, @NonNull String... supportNames)
      Type Parameters:
      S - the type of the service
      Parameters:
      serviceClass - the service
      argsType - the args type
      args - the args
      supportNames - the support service names
      Returns:
      service the service
    • unloadAll

      public static void unloadAll()
      Unload all.
    • unload

      public static <S> void unload(Class<S> service)
      Unload.
      Type Parameters:
      S - the type parameter
      Parameters:
      service - the service
    • unload

      public static <S> void unload(Class<S> service, String activateName)
      Unload.
      Type Parameters:
      S - the type parameter
      Parameters:
      service - the service
      activateName - the activate name