Package org.apache.xmlgraphics.util
Class Service
- java.lang.Object
-
- org.apache.xmlgraphics.util.Service
-
public final class Service extends java.lang.Object
This class handles looking up service providers on the class path. It implements the system described in: JAR File Specification Under Service Provider. Note that this interface is very similar to the one they describe which seems to be missing in the JDK.- Version:
- $Id$ Originally authored by Thomas DeWeese.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.Map<java.lang.String,java.util.List<java.lang.String>>
classMap
(package private) static java.util.Map<java.lang.String,java.util.List<java.lang.Object>>
instanceMap
-
Constructor Summary
Constructors Modifier Constructor Description private
Service()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private static java.lang.ClassLoader
getClassLoader(java.lang.Class<?> cls)
private static java.util.List<java.lang.String>
getProviderNames(java.lang.Class<?> cls)
private static java.util.List<java.lang.String>
getProviderNames(java.lang.Class<?> cls, java.lang.ClassLoader cl)
private static java.lang.String
getServiceFilename(java.lang.Class<?> cls)
static java.util.Iterator<java.lang.String>
providerNames(java.lang.Class<?> cls)
Returns an iterator where each element should be the name of a class that implements the interface (or subclass the baseclass) described by cls.static java.util.Iterator<java.lang.Object>
providers(java.lang.Class<?> cls)
Returns an iterator where each element should implement the interface (or subclass the baseclass) described by cls.static java.util.Iterator<?>
providers(java.lang.Class<?> cls, boolean returnInstances)
Deprecated.use the type-safe methods providers(Class) or providerNames(Class) instead.
-
-
-
Method Detail
-
providers
public static java.util.Iterator<java.lang.Object> providers(java.lang.Class<?> cls)
Returns an iterator where each element should implement the interface (or subclass the baseclass) described by cls. The Classes are found by searching the classpath for service files named: 'META-INF/services/<fully qualified classname> that list fully qualifted classnames of classes that implement the service files classes interface. These classes must have default constructors.- Parameters:
cls
- The class/interface to search for providers of.
-
providerNames
public static java.util.Iterator<java.lang.String> providerNames(java.lang.Class<?> cls)
Returns an iterator where each element should be the name of a class that implements the interface (or subclass the baseclass) described by cls. The Classes are found by searching the classpath for service files named: 'META-INF/services/<fully qualified classname> that list fully qualified classnames of classes that implement the service files classes interface.- Parameters:
cls
- The class/interface to search for providers of.
-
providers
public static java.util.Iterator<?> providers(java.lang.Class<?> cls, boolean returnInstances)
Deprecated.use the type-safe methods providers(Class) or providerNames(Class) instead.Returns an iterator where each element should implement the interface (or subclass the baseclass) described by cls. The Classes are found by searching the classpath for service files named: 'META-INF/services/<fully qualified classname> that list fully qualified classnames of classes that implement the service files classes interface. These classes must have default constructors if returnInstances is true. This is a deprecated, type-unsafe legacy method.- Parameters:
cls
- The class/interface to search for providers of.returnInstances
- true if the iterator should return instances rather than class names.
-
getProviderNames
private static java.util.List<java.lang.String> getProviderNames(java.lang.Class<?> cls)
-
getProviderNames
private static java.util.List<java.lang.String> getProviderNames(java.lang.Class<?> cls, java.lang.ClassLoader cl)
-
getClassLoader
private static java.lang.ClassLoader getClassLoader(java.lang.Class<?> cls)
-
getServiceFilename
private static java.lang.String getServiceFilename(java.lang.Class<?> cls)
-
-