Package icu.easyj.core.loader
Class EnhancedServiceLoader
java.lang.Object
icu.easyj.core.loader.EnhancedServiceLoader
The type Enhanced service loader.
注:从阿里的seata项目中复制过来的。
- Author:
- slievrly
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <S> Sload service providerstatic <S> Sload(Class<S> serviceClass, ClassLoader loader) Specify classLoader to load the service providerstatic <S> Sload service providerstatic <S> SLoad servicestatic <S> SLoad servicestatic <S> Sload(Class<S> service, String activateName, ClassLoader loader) Specify classLoader to load the service providerstatic <S> SLoad servicestatic <S> List<S>get all implementsstatic <S> List<S>get all implementsstatic <S> SloadBySupportNames(Class<S> serviceClass, Class<?>[] argsType, Object[] args, String... supportNames) static <S> SloadBySupportNames(Class<S> serviceClass, String... supportNames) static <S> voidUnload.static <S> voidUnload.static voidUnload all.
-
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 classloader- the loader- Returns:
- service the service
- Throws:
EnhancedServiceNotFoundException- the enhanced service not found exception
-
load
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 classactivateName- 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 serviceactivateName- the activate nameloader- 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 serviceactivateName- the activate nameargs- 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 serviceactivateName- the activate nameargsType- the args typeargs- 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 serviceactivateName- the activate nameargType- the only one arg typearg- the only one arg- Returns:
- service the service
- Throws:
EnhancedServiceNotFoundException- the enhanced service not found exception
-
loadAll
get all implements- Type Parameters:
S- the type of the service- Parameters:
serviceClass- the service class- Returns:
- list the service list
-
loadAll
get all implements- Type Parameters:
S- the type of the service- Parameters:
serviceClass- the serviceargsType- the args typeargs- the args- Returns:
- list the service list
-
loadBySupportNames
- Type Parameters:
S- the type of the service- Parameters:
serviceClass- the servicesupportNames- 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 serviceargsType- the args typeargs- the argssupportNames- the support service names- Returns:
- service the service
-
unloadAll
public static void unloadAll()Unload all. -
unload
Unload.- Type Parameters:
S- the type parameter- Parameters:
service- the service
-
unload
Unload.- Type Parameters:
S- the type parameter- Parameters:
service- the serviceactivateName- the activate name
-