org.freecompany.util.services
public class ServiceInfo extends Object
Field Summary | |
---|---|
protected Properties | properties |
protected String | system |
Constructor Summary | |
---|---|
protected | ServiceInfo()
Constructs a service information object without an associated system identifier. |
protected | ServiceInfo(String system)
Constructs a service information object with the given system identifier. |
Method Summary | |
---|---|
protected static String | clean(String line)
Utility method to remove comments from service descriptors. |
protected static <T> T | createInstance(ClassLoader loader, String name, Class<T> service)
Attempts to create an instance of the named class using the provided class loader. |
<T> T | findService(Class<T> service)
Finds the first known implementation of the given service class (or interface) using the current
class loader. |
<T> T | findService(ClassLoader loader, Class<T> service)
Finds the first known implementation of the given service class (or interface) using the provided
class loader. |
<T> Iterable<T> | findServices(Class<T> service)
Finds all known implementations of the given service class using the current class loader.
|
<T> Iterable<T> | findServices(ClassLoader loader, Class<T> service)
Finds all known implementations of the given service class using the provided class loader. |
String | getSystem()
Gets the system name, used to find system wide service properties.
|
protected static <T> Collection<T> | searchClassPath(ClassLoader loader, Class<T> service)
Finds all service descriptors that contain an implementation of the given service. |
Parameters: system the identifier for the particular system, i.e. {@code net}, for which properties should be parsed.
Parameters: line line including possible extra white space and comment.
Returns: cleaned line or the empty string if the line is not valid.
Parameters: loader the class loader to use to load the class definition, may be {@code null}. name name of the class to load and instantiate. service the service class of which the named class is expected to be a subclass.
Returns: a new instance of the class indicated with {@code name}.
Throws: ClassCastException if the named class is not a subclass of {@code service}.
Parameters: service the service class (or interface) for which a compatible implementation will be returned.
Returns: a concrete instance, or {@code null} if none is found.
Parameters: loader the class loader to use when searching for service descriptor files, or {@code null} to use the current class loader. service the service class (or interface) for which compatible implementations will be returned.
Returns: a concrete instance, or {@code null} if none is found.
Throws: ClassCastException if a found provider class is not a subclass of {@code service}.
Parameters: service the service class (or interface) for which compatible implementations will be searched.
Returns: a Collection of concrete instances, or the empty collection is none is found.
Throws: ClassCastException if a found provider class is not a subclass of {@code service}.
Parameters: loader the class loader to use when searching for service descriptor files, or {@code null} to use the current class loader. service the service class (or interface) for which compatible implementations will be searched.
Returns: a Collection of concrete instances, or the empty collection is none is found.
Throws: ClassCastException if a found provider class is not a subclass of {@code service}.
Returns: the system name, or {@code null} if none was set.
Parameters: loader the class loader within which to search for service descriptors. service the service interface for which to find concrete implementations.
Returns: a Collection of concrete instances of the service class (or interface), or an empty collection if none could be found.
Throws: ClassCastException if a found provider class is not a subclass of {@code service}.