Package io.microsphere.util
Class ServiceLoaderUtils
- java.lang.Object
-
- io.microsphere.util.ServiceLoaderUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <S> S
loadFirstService(java.lang.Class<S> serviceType)
Load the first instance ofService interface instances list
static <S> S
loadFirstService(java.lang.Class<S> serviceType, boolean cached)
Load the first instance ofService interface instances list
static <S> S
loadFirstService(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader)
Load the first instance ofService interface instances list
static <S> S
loadFirstService(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader, boolean cached)
Load the first instance ofService interface instances list
static <S> S
loadLastService(java.lang.Class<S> serviceType)
Loads the last in the list of objects implementing the service type, if present.static <S> S
loadLastService(java.lang.Class<S> serviceType, boolean cached)
Loads the last in the list of objects implementing the service type, if present.static <S> S
loadLastService(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader)
Loads the last in the list of objects implementing the service type, if present.static <S> S
loadLastService(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader, boolean cached)
Loads the last in the list of objects implementing the service type, if present.static <S> S[]
loadServices(java.lang.Class<S> serviceType)
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path.
static <S> S[]
loadServices(java.lang.Class<S> serviceType, boolean cached)
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path.
static <S> S[]
loadServices(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader)
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path.
static <S> S[]
loadServices(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader, boolean cached)
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path.
static <S> java.util.List<S>
loadServicesList(java.lang.Class<S> serviceType)
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path.
static <S> java.util.List<S>
loadServicesList(java.lang.Class<S> serviceType, boolean cached)
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path.
static <S> java.util.List<S>
loadServicesList(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader)
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path.
static <S> java.util.List<S>
loadServicesList(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader, boolean cached)
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path.
-
-
-
Method Detail
-
loadServicesList
public static <S> java.util.List<S> loadServicesList(java.lang.Class<S> serviceType) throws java.lang.IllegalArgumentException
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path. The configuration file of each service type can define multiple lists of implementation classes.
- Type Parameters:
S
- service type- Parameters:
serviceType
- service type- Returns:
- service type all implementation objects of
readonly list
- Throws:
java.lang.IllegalArgumentException
- If it refers to the implementation class that does not defineserviceType
in the configuration file /META-INF/services/
serviceType
-
loadServicesList
public static <S> java.util.List<S> loadServicesList(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader) throws java.lang.IllegalArgumentException
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path. The configuration file of each service type can define multiple lists of implementation classes.
- Type Parameters:
S
- service type- Parameters:
serviceType
- service typeclassLoader
-ClassLoader
- Returns:
- service type all implementation objects of
readonly list
- Throws:
java.lang.IllegalArgumentException
- If it refers to the implementation class that does not defineserviceType
in the configuration file /META-INF/services/
serviceType
-
loadServicesList
public static <S> java.util.List<S> loadServicesList(java.lang.Class<S> serviceType, boolean cached) throws java.lang.IllegalArgumentException
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path. The configuration file of each service type can define multiple lists of implementation classes.
- Type Parameters:
S
- service type- Parameters:
serviceType
- service typecached
- the list of services to be cached- Returns:
- service type all implementation objects of
readonly list
- Throws:
java.lang.IllegalArgumentException
- If it refers to the implementation class that does not defineserviceType
in the configuration file /META-INF/services/
serviceType
-
loadServicesList
public static <S> java.util.List<S> loadServicesList(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader, boolean cached) throws java.lang.IllegalArgumentException
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path. The configuration file of each service type can define multiple lists of implementation classes.
- Type Parameters:
S
- service type- Parameters:
serviceType
- service typeclassLoader
-ClassLoader
cached
- the list of services to be cached- Returns:
- service type all implementation objects of
readonly list
- Throws:
java.lang.IllegalArgumentException
- If it refers to the implementation class that does not defineserviceType
in the configuration file /META-INF/services/
serviceType
-
loadServices
public static <S> S[] loadServices(java.lang.Class<S> serviceType) throws java.lang.IllegalArgumentException
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path. The configuration file of each service type can define multiple lists of implementation classes.
- Type Parameters:
S
- service type- Parameters:
serviceType
- service type- Returns:
- service type all implementation objects
- Throws:
java.lang.IllegalArgumentException
- If it refers to the implementation class that does not defineserviceType
in the configuration file /META-INF/services/
serviceType
-
loadServices
public static <S> S[] loadServices(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader) throws java.lang.IllegalArgumentException
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path. The configuration file of each service type can define multiple lists of implementation classes.
- Type Parameters:
S
- service type- Parameters:
serviceType
- service typeclassLoader
-ClassLoader
- Returns:
- service type all implementation objects
- Throws:
java.lang.IllegalArgumentException
- If it refers to the implementation class that does not defineserviceType
in the configuration file /META-INF/services/
serviceType
-
loadServices
public static <S> S[] loadServices(java.lang.Class<S> serviceType, boolean cached) throws java.lang.IllegalArgumentException
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path. The configuration file of each service type can define multiple lists of implementation classes.
- Type Parameters:
S
- service type- Parameters:
serviceType
- service typecached
- the list of services to be cached- Returns:
- service type all implementation objects
- Throws:
java.lang.IllegalArgumentException
- If it refers to the implementation class that does not defineserviceType
in the configuration file /META-INF/services/
serviceType
-
loadServices
public static <S> S[] loadServices(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader, boolean cached) throws java.lang.IllegalArgumentException
Using the hierarchy ofClassLoader
, each level of ClassLoader ( ClassLoader , its parent ClassLoader and higher) will be able to load the configuration file META-INF/servicesserviceType
under its class path. The configuration file of each service type can define multiple lists of implementation classes.
- Type Parameters:
S
- service type- Parameters:
serviceType
- service typeclassLoader
-ClassLoader
cached
- the list of services to be cached- Returns:
- service type all implementation objects
- Throws:
java.lang.IllegalArgumentException
- If it refers to the implementation class that does not defineserviceType
in the configuration file /META-INF/services/
serviceType
-
loadFirstService
public static <S> S loadFirstService(java.lang.Class<S> serviceType) throws java.lang.IllegalArgumentException
Load the first instance ofService interface instances list
Design Purpose : Using the hierarchy ofClassLoader
, each level of ClassLoader will be able to access the configuration files under its class path /META-INF/services/serviceType
. Then, override the first implementation class of the configuration file under the class path of ClassLoader, thereby providing a mechanism for overriding the implementation class.- Type Parameters:
S
- service type- Parameters:
serviceType
- service type- Returns:
- If it exists,
loads the first in the list of implementation objects of service type
. - Throws:
java.lang.IllegalArgumentException
- If the implementation class that does not defineserviceType
is in the configuration file META-INF/services/
serviceType
, IllegalArgumentException will be thrown
-
loadFirstService
public static <S> S loadFirstService(java.lang.Class<S> serviceType, boolean cached) throws java.lang.IllegalArgumentException
Load the first instance ofService interface instances list
Design Purpose : Using the hierarchy ofClassLoader
, each level of ClassLoader will be able to access the configuration files under its class path /META-INF/services/serviceType
. Then, override the first implementation class of the configuration file under the class path of ClassLoader, thereby providing a mechanism for overriding the implementation class.- Type Parameters:
S
- service type- Parameters:
serviceType
- service typecached
- the list of services to be cached- Returns:
- If it exists,
loads the first in the list of implementation objects of service type
. - Throws:
java.lang.IllegalArgumentException
- If the implementation class that does not defineserviceType
is in the configuration file META-INF/services/
serviceType
, IllegalArgumentException will be thrown
-
loadFirstService
public static <S> S loadFirstService(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader) throws java.lang.IllegalArgumentException
Load the first instance ofService interface instances list
Design Purpose : Using the hierarchy ofClassLoader
, each level of ClassLoader will be able to access the configuration files under its class path /META-INF/services/serviceType
. Then, override the first implementation class of the configuration file under the class path of ClassLoader, thereby providing a mechanism for overriding the implementation class.- Type Parameters:
S
- service type- Parameters:
serviceType
- service type- Returns:
- If it exists,
loads the first in the list of implementation objects of service type
. - Throws:
java.lang.IllegalArgumentException
- If the implementation class that does not defineserviceType
is in the configuration file META-INF/services/
serviceType
, IllegalArgumentException will be thrown
-
loadFirstService
public static <S> S loadFirstService(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader, boolean cached) throws java.lang.IllegalArgumentException
Load the first instance ofService interface instances list
Design Purpose : Using the hierarchy ofClassLoader
, each level of ClassLoader will be able to access the configuration files under its class path /META-INF/services/serviceType
. Then, override the first implementation class of the configuration file under the class path of ClassLoader, thereby providing a mechanism for overriding the implementation class.- Type Parameters:
S
- service type- Parameters:
serviceType
- service typecached
- the list of services to be cached- Returns:
- If it exists,
loads the first in the list of implementation objects of service type
. - Throws:
java.lang.IllegalArgumentException
- If the implementation class that does not defineserviceType
is in the configuration file META-INF/services/
serviceType
, IllegalArgumentException will be thrown
-
loadLastService
public static <S> S loadLastService(java.lang.Class<S> serviceType) throws java.lang.IllegalArgumentException
Loads the last in the list of objects implementing the service type, if present. Design Purpose : Using the hierarchy ofClassLoader
, once the configuration file is loaded in the parent's ClassLoader at a higher level (here the highest-level ClassLoader is Bootstrap ClassLoader) /META-INF/services/serviceType
If the last implementation class is used, the lower-level Class Loader will not be able to override the previous definition。- Type Parameters:
S
- service type- Parameters:
serviceType
- service type- Returns:
- Loads the last in the list of objects implementing the service type, if present.
- Throws:
java.lang.IllegalArgumentException
- seeloadServicesList(Class, ClassLoader)
-
loadLastService
public static <S> S loadLastService(java.lang.Class<S> serviceType, boolean cached) throws java.lang.IllegalArgumentException
Loads the last in the list of objects implementing the service type, if present. Design Purpose : Using the hierarchy ofClassLoader
, once the configuration file is loaded in the parent's ClassLoader at a higher level (here the highest-level ClassLoader is Bootstrap ClassLoader) /META-INF/services/serviceType
If the last implementation class is used, the lower-level Class Loader will not be able to override the previous definition。- Type Parameters:
S
- service type- Parameters:
serviceType
- service typecached
- the list of services to be cached- Returns:
- Loads the last in the list of objects implementing the service type, if present.
- Throws:
java.lang.IllegalArgumentException
- seeloadServicesList(Class, ClassLoader)
-
loadLastService
public static <S> S loadLastService(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader) throws java.lang.IllegalArgumentException
Loads the last in the list of objects implementing the service type, if present. Design Purpose : Using the hierarchy ofClassLoader
, once the configuration file is loaded in the parent's ClassLoader at a higher level (here the highest-level ClassLoader is Bootstrap ClassLoader) /META-INF/services/serviceType
If the last implementation class is used, the lower-level Class Loader will not be able to override the previous definition。- Type Parameters:
S
- service type- Parameters:
serviceType
- service typeclassLoader
-ClassLoader
- Returns:
- Loads the last in the list of objects implementing the service type, if present.
- Throws:
java.lang.IllegalArgumentException
- seeloadServicesList(Class, ClassLoader)
-
loadLastService
public static <S> S loadLastService(java.lang.Class<S> serviceType, java.lang.ClassLoader classLoader, boolean cached) throws java.lang.IllegalArgumentException
Loads the last in the list of objects implementing the service type, if present. Design Purpose : Using the hierarchy ofClassLoader
, once the configuration file is loaded in the parent's ClassLoader at a higher level (here the highest-level ClassLoader is Bootstrap ClassLoader) /META-INF/services/serviceType
If the last implementation class is used, the lower-level Class Loader will not be able to override the previous definition。- Type Parameters:
S
- service type- Parameters:
serviceType
- service type- Returns:
- Loads the last in the list of objects implementing the service type, if present.
- Throws:
java.lang.IllegalArgumentException
- seeloadServicesList(Class, ClassLoader)
-
-