Utility class used to instantiate an object using reflection. This utility
hides many of the gory details needed to do this.
_getMethod
private Method _getMethod(Class targetClass,
String methodName,
Class[] params)
throws ReflectorException
getConstructor
public Constructor getConstructor(Class targetClass,
Class[] params)
throws ReflectorException Return the constructor, checking the cache first and storing in cache if
not already there..
targetClass - The class to get the constructor fromparams - The classes of the parameters which the constructor should
match.
- the Constructor object that matches.
getConstructorMap
private Map getConstructorMap(Class theClass)
throws ReflectorException Retrieve the cache of constructors for the specified class.
theClass - the class to lookup.
- The cache of constructors.
getField
public Object getField(Object target,
String fieldName,
boolean breakAccessibility)
throws ReflectorException
getMethod
public Method getMethod(Class targetClass,
String methodName,
Class[] params)
throws ReflectorException Return the method, checking the cache first and storing in cache if not
already there..
targetClass - The class to get the method fromparams - The classes of the parameters which the method should match.
- the Method object that matches.
getMethodMap
private Map getMethodMap(Class theClass,
String methodName)
throws ReflectorException Retrieve the cache of methods for the specified class and method name.
theClass - the class to lookup.methodName - The name of the method to lookup.
- The cache of constructors.
getObjectProperty
public Object getObjectProperty(Object target,
String propertyName)
throws ReflectorException
getSingleton
public Object getSingleton(Class theClass,
Object[] initParams)
throws ReflectorException Retrieve the singleton instance of a class, given the array of
parameters... Uses constructor caching to find a constructor that matches
the parameter types, either specifically (first choice) or abstractly...
theClass - The class to retrieve the singleton ofinitParams - The parameters to pass to the constructor
getStaticField
public Object getStaticField(Class targetClass,
String fieldName)
throws ReflectorException
invoke
public Object invoke(Object target,
String methodName,
Object[] params)
throws ReflectorException Invoke the specified method on the specified target with the specified
params...
target - The target of the invocationmethodName - The method name to invokeparams - The parameters to pass to the method invocation
- The result of the method call
invokeStatic
public Object invokeStatic(Class targetClass,
String methodName,
Object[] params)
throws ReflectorException Invoke the specified static method with the specified params...
targetClass - The target class of the invocationmethodName - The method name to invokeparams - The parameters to pass to the method invocation
- The result of the method call
newInstance
public Object newInstance(Class theClass,
Object[] params)
throws ReflectorException Create a new instance of a class, given the array of parameters... Uses
constructor caching to find a constructor that matches the parameter
types, either specifically (first choice) or abstractly...
theClass - The class to instantiateparams - The parameters to pass to the constructor