|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectDiscoveryUtils
public class DiscoveryUtils
Utility methods for discovering implementor classes on the classpath. An implementor class is declared in the standard way, in a file within META-INF/services where the file name is the class name of the desired interface, and the file contains the class name of the implementation. For example, to declare test.MyServiceImpl as a test.MyService implementation, the file META-INF/services/test.MyService is put on classpath (e.g., in a JAR), with contents "test.MyServiceImpl".
Constructor Summary | |
---|---|
DiscoveryUtils()
|
Method Summary | |
---|---|
static ClassLoader |
getClassLoader()
Get the ClassLoader from which implementor classes will be discovered and loaded. |
static Class[] |
getImplementorClasses(Class interfaceType)
Get all implementor classes (on the context classpath) that implement a given interface. |
static Class |
loadImplementorClass(String className,
Class interfaceType)
Load an implementor class from the context classloader. |
static Object |
newImplementorInstance(String className,
Class interfaceType)
|
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DiscoveryUtils()
Method Detail |
---|
public static ClassLoader getClassLoader()
public static Class[] getImplementorClasses(Class interfaceType)
interfaceType
- the Class that represents the interface.
interfaceType
.public static Object newImplementorInstance(String className, Class interfaceType)
public static Class loadImplementorClass(String className, Class interfaceType)
className
- the name of the implementor class.interfaceType
- the interface that the given class should implement.
null
if an error occurred (the error will be logged).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |