org.apache.beehive.netui.util
Class DiscoveryUtils

Object
  extended by DiscoveryUtils

public class DiscoveryUtils
extends Object

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

DiscoveryUtils

public DiscoveryUtils()
Method Detail

getClassLoader

public static ClassLoader getClassLoader()
Get the ClassLoader from which implementor classes will be discovered and loaded.


getImplementorClasses

public static Class[] getImplementorClasses(Class interfaceType)
Get all implementor classes (on the context classpath) that implement a given interface.

Parameters:
interfaceType - the Class that represents the interface.
Returns:
an array of Classes that are implementations of interfaceType.

newImplementorInstance

public static Object newImplementorInstance(String className,
                                            Class interfaceType)

loadImplementorClass

public static Class loadImplementorClass(String className,
                                         Class interfaceType)
Load an implementor class from the context classloader.

Parameters:
className - the name of the implementor class.
interfaceType - the interface that the given class should implement.
Returns:
the implementor Class, or null if an error occurred (the error will be logged).