|
Oracle | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.compoze.util.ServiceRegistry
public class ServiceRegistry
This class is a generic registry of interfaces that are used to provide services. It maps interfaces to the classes that implement them. By switching the implementing class of a given interface in the registry the runtime behavior of the code may be customized. It can be used to allow for "pluggable" implementations of an interface, configurable at runtime by a passed in Properties object.
Constructor Summary | |
---|---|
ServiceRegistry(java.util.Properties props)
Constructor. |
Method Summary | |
---|---|
java.lang.Class |
get(java.lang.Class interfaceClass)
Get the implementing class of the specified interface. |
java.lang.Class |
get(java.lang.Class interfaceClass,
java.lang.ClassLoader classLoader)
Get the implementing class of the specified interface. |
java.lang.Object |
getInstance(java.lang.Class interfaceClass)
Create an instance of the implementor of the specified interface using its default constructor. |
java.lang.Object |
getInstance(java.lang.Class interfaceClass,
java.lang.Class[] constructorArgTypes,
java.lang.Object[] constructorArgs)
Create an instance of the implementor of the specified interface using the specified constructor. |
java.lang.Object |
getInstance(java.lang.Class interfaceClass,
java.lang.Class[] constructorArgTypes,
java.lang.Object[] constructorArgs,
java.lang.ClassLoader classLoader)
Create an instance of the implementor of the specified interface using the specified constructor. |
java.lang.Object |
getInstance(java.lang.Class interfaceClass,
java.lang.ClassLoader classLoader)
Create an instance of the implementor of the specified interface using its default constructor. |
java.lang.Object |
getMappedInstance(java.lang.Class interfaceClass,
java.lang.Object keyObject)
Create an instance of the implementor of the specified interface using its default constructor. |
java.lang.Object |
getMappedInstance(java.lang.Class interfaceClass,
java.lang.Object keyObject,
java.lang.Class[] constructorArgTypes,
java.lang.Object[] constructorArgs)
Create an instance of the implementor of the specified interface using the specified constructor. |
java.lang.Object |
getMappedInstance(java.lang.Class interfaceClass,
java.lang.Object keyObject,
java.lang.Class[] constructorArgTypes,
java.lang.Object[] constructorArgs,
java.lang.ClassLoader classLoader)
Create an instance of the implementor of the specified interface using the specified constructor. |
java.lang.Object |
getMappedInstance(java.lang.Class interfaceClass,
java.lang.Object keyObject,
java.lang.ClassLoader classLoader)
Create an instance of the implementor of the specified interface using its default constructor. |
java.lang.Class |
getService(java.lang.Class interfaceClass)
Get a service from an interface class. |
java.lang.Class |
getService(java.lang.Class interfaceClass,
java.lang.ClassLoader classLoader)
Get a service from an interface class. |
java.lang.Object |
getSingletonInstance(java.lang.Class interfaceClass)
Create an instance of the implementor of the specified interface using its default constructor. |
java.lang.Object |
getSingletonInstance(java.lang.Class interfaceClass,
java.lang.Class[] constructorArgTypes,
java.lang.Object[] constructorArgs)
Create an instance of the implementor of the specified interface using the specified constructor. |
java.lang.Object |
getSingletonInstance(java.lang.Class interfaceClass,
java.lang.Class[] constructorArgTypes,
java.lang.Object[] constructorArgs,
java.lang.ClassLoader classLoader)
Create an instance of the implementor of the specified interface using the specified constructor. |
java.lang.Object |
getSingletonInstance(java.lang.Class interfaceClass,
java.lang.ClassLoader classLoader)
Create an instance of the implementor of the specified interface using its default constructor. |
static void |
main(java.lang.String[] args)
Exerciser. |
void |
set(java.lang.Class interfaceClass,
java.lang.Class implementingClass)
Set the implementor of the specified interface. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ServiceRegistry(java.util.Properties props)
props
- the properties to read the services fromMethod Detail |
---|
public java.lang.Class get(java.lang.Class interfaceClass)
interfaceClass
- the class of the interface
public java.lang.Class get(java.lang.Class interfaceClass, java.lang.ClassLoader classLoader)
interfaceClass
- the class of the interfaceclassLoader
- the class loader to look for class in
public java.lang.Object getInstance(java.lang.Class interfaceClass) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
interfaceClass
- the class of the interface
java.lang.IllegalAccessException
- if the implementing class could not be accessed
java.lang.InstantiationException
- if the implementing class could not be instantiated
java.lang.NoSuchMethodException
- if the specified constructor does not exist
java.lang.reflect.InvocationTargetException
- if the specified constructor could not be invokedpublic java.lang.Object getInstance(java.lang.Class interfaceClass, java.lang.ClassLoader classLoader) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
interfaceClass
- the class of the interfaceclassLoader
- the class loader to look for class in
java.lang.IllegalAccessException
- if the implementing class could not be accessed
java.lang.InstantiationException
- if the implementing class could not be instantiated
java.lang.NoSuchMethodException
- if the specified constructor does not exist
java.lang.reflect.InvocationTargetException
- if the specified constructor could not be invokedpublic java.lang.Object getInstance(java.lang.Class interfaceClass, java.lang.Class[] constructorArgTypes, java.lang.Object[] constructorArgs) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
interfaceClass
- the class of the interfaceconstructorArgTypes
- argument types of the desired constructorconstructorArgs
- arguments for the desired constructor
java.lang.IllegalAccessException
- if the implementing class could not be accessed
java.lang.InstantiationException
- if the implementing class could not be instantiated
java.lang.NoSuchMethodException
- if the specified constructor does not exist
java.lang.reflect.InvocationTargetException
- if the specified constructor could not be invokedpublic java.lang.Object getInstance(java.lang.Class interfaceClass, java.lang.Class[] constructorArgTypes, java.lang.Object[] constructorArgs, java.lang.ClassLoader classLoader) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
interfaceClass
- the class of the interfaceconstructorArgTypes
- argument types of the desired constructorconstructorArgs
- arguments for the desired constructorclassLoader
- the class loader to look for class in
java.lang.IllegalAccessException
- if the implementing class could not be accessed
java.lang.InstantiationException
- if the implementing class could not be instantiated
java.lang.NoSuchMethodException
- if the specified constructor does not exist
java.lang.reflect.InvocationTargetException
- if the specified constructor could not be invokedpublic java.lang.Object getMappedInstance(java.lang.Class interfaceClass, java.lang.Object keyObject) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
interfaceClass
- the class of the interfacekeyObject
- the key object in the map
java.lang.IllegalAccessException
- if the implementing class could not be accessed
java.lang.InstantiationException
- if the implementing class could not be instantiated
java.lang.NoSuchMethodException
- if the specified constructor does not exist
java.lang.reflect.InvocationTargetException
- if the specified constructor could not be invokedpublic java.lang.Object getMappedInstance(java.lang.Class interfaceClass, java.lang.Object keyObject, java.lang.ClassLoader classLoader) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
interfaceClass
- the class of the interfacekeyObject
- the key object in the mapkeyObject
- the key object in the mapclassLoader
- the class loader to look for class in
java.lang.IllegalAccessException
- if the implementing class could not be accessed
java.lang.InstantiationException
- if the implementing class could not be instantiated
java.lang.NoSuchMethodException
- if the specified constructor does not exist
java.lang.reflect.InvocationTargetException
- if the specified constructor could not be invokedpublic java.lang.Object getMappedInstance(java.lang.Class interfaceClass, java.lang.Object keyObject, java.lang.Class[] constructorArgTypes, java.lang.Object[] constructorArgs) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
interfaceClass
- the class of the interfacekeyObject
- the key object in the mapconstructorArgTypes
- argument types of the desired constructorconstructorArgs
- arguments for the desired constructor
java.lang.IllegalAccessException
- if the implementing class could not be accessed
java.lang.InstantiationException
- if the implementing class could not be instantiated
java.lang.NoSuchMethodException
- if the specified constructor does not exist
java.lang.reflect.InvocationTargetException
- if the specified constructor could not be invokedpublic java.lang.Object getMappedInstance(java.lang.Class interfaceClass, java.lang.Object keyObject, java.lang.Class[] constructorArgTypes, java.lang.Object[] constructorArgs, java.lang.ClassLoader classLoader) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
interfaceClass
- the class of the interfacekeyObject
- the key object in the mapconstructorArgTypes
- argument types of the desired constructorconstructorArgs
- arguments for the desired constructorclassLoader
- the class loader to look for class in
java.lang.IllegalAccessException
- if the implementing class could not be accessed
java.lang.InstantiationException
- if the implementing class could not be instantiated
java.lang.NoSuchMethodException
- if the specified constructor does not exist
java.lang.reflect.InvocationTargetException
- if the specified constructor could not be invokedpublic java.lang.Object getSingletonInstance(java.lang.Class interfaceClass) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
interfaceClass
- the class of the interface
java.lang.IllegalAccessException
- if the implementing class could not be accessed
java.lang.InstantiationException
- if the implementing class could not be instantiated
java.lang.NoSuchMethodException
- if the specified constructor does not exist
java.lang.reflect.InvocationTargetException
- if the specified constructor could not be invokedpublic java.lang.Object getSingletonInstance(java.lang.Class interfaceClass, java.lang.ClassLoader classLoader) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
interfaceClass
- the class of the interfaceclassLoader
- the class loader to look for class in
java.lang.IllegalAccessException
- if the implementing class could not be accessed
java.lang.InstantiationException
- if the implementing class could not be instantiated
java.lang.NoSuchMethodException
- if the specified constructor does not exist
java.lang.reflect.InvocationTargetException
- if the specified constructor could not be invokedpublic java.lang.Object getSingletonInstance(java.lang.Class interfaceClass, java.lang.Class[] constructorArgTypes, java.lang.Object[] constructorArgs) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
interfaceClass
- the class of the interfaceconstructorArgTypes
- argument types of the desired constructorconstructorArgs
- arguments for the desired constructor
java.lang.IllegalAccessException
- if the implementing class could not be accessed
java.lang.InstantiationException
- if the implementing class could not be instantiated
java.lang.NoSuchMethodException
- if the specified constructor does not exist
java.lang.reflect.InvocationTargetException
- if the specified constructor could not be invokedpublic java.lang.Object getSingletonInstance(java.lang.Class interfaceClass, java.lang.Class[] constructorArgTypes, java.lang.Object[] constructorArgs, java.lang.ClassLoader classLoader) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
interfaceClass
- the class of the interfaceconstructorArgTypes
- argument types of the desired constructorconstructorArgs
- arguments for the desired constructorclassLoader
- the class loader to look for class in
java.lang.IllegalAccessException
- if the implementing class could not be accessed
java.lang.InstantiationException
- if the implementing class could not be instantiated
java.lang.NoSuchMethodException
- if the specified constructor does not exist
java.lang.reflect.InvocationTargetException
- if the specified constructor could not be invokedpublic void set(java.lang.Class interfaceClass, java.lang.Class implementingClass)
interfaceClass
- the class of the interfaceimplementingClass
- the class that implements the interfacepublic java.lang.Class getService(java.lang.Class interfaceClass)
interfaceClass
-
public java.lang.Class getService(java.lang.Class interfaceClass, java.lang.ClassLoader classLoader)
interfaceClass
- classLoader
- the class loader to look for class in
public static void main(java.lang.String[] args)
args
- arguments (first is name of properties file)
|
Oracle | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |