ServiceLoader class methods in Java

java.util.ServiceLoader

A facility to load implementations of a service. A service is a well-known interface or class for which zero, one, or many service providers exist.

Some methods of ServiceLoader class


equals(Object): This method indicates whether some other object is "equal to" this one.


findFirst(): This method loads the first available service provider of this loader's service.


hashCode(): This method returns a hash code value for the object.


iterator(): This method returns an iterator to lazily load and instantiate the available providers of this loader's service.


load(Class): This method creates a new service loader for the given service type, using the current thread's context class loader.


load(Class, ClassLoader): This method creates a new service loader for the given service.


load(ModuleLayer, Class): This method creates a new service loader for the given service type to load service providers from modules in the given module layer and its ancestors.


loadInstalled(Class): This method creates a new service loader for the given service type, using the platform class loader.


reload(): This method clears this loader's provider cache so that all providers will be reloaded.


spliterator(): This method creates a Spliterator over the elements described by this Iterable.


stream(): This method returns a stream to lazily load available providers of this loader'sservice.


toString(): This method returns a string describing this service.


No comments:

Post a Comment