Package org.jppf.utils
Class ServiceFinder
java.lang.Object
org.jppf.utils.ServiceFinder
Instances of this class look for and find services implemented via the Service Provider Interface (SPI).
This class is an alternative for the static methods found in
ServiceRegistry.- Author:
- Laurent Cohen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindProviderClassess(Class<T> providerClass, ClassLoader loader, boolean single) Find the classes of all providers implementing or extending the specified provider interface or class, using the specified class loader.<T> List<T>findProviders(Class<T> providerClass) Find all providers implementing or extending the specified provider interface or class, using the context class loader.<T> List<T>findProviders(Class<T> providerClass, ClassLoader cl) Find all providers implementing or extending the specified provider interface or class, using the specified class loader.<T> List<T>findProviders(Class<T> providerClass, ClassLoader cl, boolean single) Find all providers implementing or extending the specified provider interface or class, using the specified class loader.findServiceDefinitions(String path, ClassLoader cl) Find all service definitions in the classpath, that match the specified path.static <T> Iterator<T>lookupProviders(Class<T> providerClass) Find all providers implementing or extending the specified provider interface or class, using the context class loader.static <T> Iterator<T>lookupProviders(Class<T> providerClass, ClassLoader cl) Find all providers implementing or extending the specified provider interface or class, using the specified class loader.static <T> Iterator<T>lookupProviders(Class<T> providerClass, ClassLoader cl, boolean single) Find all providers implementing or extending the specified provider interface or class, using the specified class loader.
-
Constructor Details
-
ServiceFinder
public ServiceFinder()
-
-
Method Details
-
findProviderClassess
public <T> List<Class<? extends T>> findProviderClassess(Class<T> providerClass, ClassLoader loader, boolean single) Find the classes of all providers implementing or extending the specified provider interface or class, using the specified class loader.- Type Parameters:
T- The type of provider implementations to find.- Parameters:
providerClass- the provider class.loader- the class loader to use for the lookup.single- determines whether only the first looked up provider should be returned, or all the providers found.- Returns:
- a list of concrete providers of the specified type.
-
findProviders
Find all providers implementing or extending the specified provider interface or class, using the specified class loader.- Type Parameters:
T- The type of provider implementations to find.- Parameters:
providerClass- the provider class.cl- the class loader to use for the lookup.single- determines whether only the first looked up provider should be returned, or all the providers found.- Returns:
- a list of concrete providers of the specified type.
-
findProviders
Find all providers implementing or extending the specified provider interface or class, using the specified class loader.- Type Parameters:
T- The type of provider implementations to find.- Parameters:
providerClass- the provider class.cl- the class loader to user for the lookup.- Returns:
- a list of concrete providers of the specified type.
-
findProviders
Find all providers implementing or extending the specified provider interface or class, using the context class loader.- Type Parameters:
T- The type of provider implementations to find.- Parameters:
providerClass- the provider class.- Returns:
- a list of concrete providers of the specified type.
-
findServiceDefinitions
Find all service definitions in the classpath, that match the specified path.- Parameters:
path- the path to the definition files to find.cl- the class loader to use for classpath lookup.- Returns:
- the definitions found as a list of strings.
-
lookupProviders
public static <T> Iterator<T> lookupProviders(Class<T> providerClass, ClassLoader cl, boolean single) Find all providers implementing or extending the specified provider interface or class, using the specified class loader.- Type Parameters:
T- The type of provider implementations to find.- Parameters:
providerClass- the provider class.cl- the class loader to user for the lookup.single- determines whether only the first looked up provider should be returned, or all the providers found.- Returns:
- an iterator over concrete providers of the specified type.
-
lookupProviders
Find all providers implementing or extending the specified provider interface or class, using the specified class loader.- Type Parameters:
T- The type of provider implementations to find.- Parameters:
providerClass- the provider class.cl- the class loader to user for the lookup.- Returns:
- an iterator over concrete providers of the specified type.
-
lookupProviders
Find all providers implementing or extending the specified provider interface or class, using the context class loader.- Type Parameters:
T- The type of provider implementations to find.- Parameters:
providerClass- the provider class.- Returns:
- an iterator over concrete providers of the specified type.
-