Package org.jppf.utils
Class ServiceProviderHandler<T>
java.lang.Object
org.jppf.utils.ServiceProviderHandler<T>
- Type Parameters:
T- the type of the SPI interface.
A utility class that handles a SPI mechanism. It loads all implementations of a service provider interface found in the classpath and provides access to them.
- Author:
- Laurent Cohen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ClassLoaderThe class loader used to lookup the service implementations.The interface to handle.The list of provider instances. -
Constructor Summary
ConstructorsConstructorDescriptionServiceProviderHandler(Class<T> inf) ServiceProviderHandler(Class<T> inf, ClassLoader classLoader) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProvider(T provider) Add a providers to the list of providers.Get all the rpoviders loaded by htis handler.voidLoad all provider instances found in the class path via a service definition.voidRemove all providers from the list of providers.voidremoveProvider(T provider) Remove a listener from the list of providers.
-
Field Details
-
inf
The interface to handle. -
providers
The list of provider instances. -
classLoader
The class loader used to lookup the service implementations.
-
-
Constructor Details
-
ServiceProviderHandler
- Parameters:
inf- the service interface to handle.
-
ServiceProviderHandler
- Parameters:
inf- the service interface to handle.classLoader- the class loader used to lookup the service implementations.
-
-
Method Details
-
addProvider
Add a providers to the list of providers.- Parameters:
provider- the provider to add.
-
removeProvider
Remove a listener from the list of providers.- Parameters:
provider- the provider to remove.
-
removeAllProviders
public void removeAllProviders()Remove all providers from the list of providers. -
getProviders
Get all the rpoviders loaded by htis handler.- Returns:
- a List of provider implementations.
-
loadProviders
public void loadProviders()Load all provider instances found in the class path via a service definition.
-