This file is a collection of reflection utilities. There are utilities
for creating beans, getting bean infos, setting/getting properties,
and binding events.
addEventListener
public static void addEventListener(Object source,
String eventSetName,
EventProcessor processor)
throws IntrospectionException,
IllegalArgumentException,
IllegalAccessException,
InstantiationException,
InvocationTargetException
Add an event processor as a listener to some event coming out of an
object.
source
- event sourceeventSetName
- name of event set from event src to bind toprocessor
- event processor the event should be delegated to
when it occurs; either via processEvent or
processExceptionableEvent.
createBean
public static Bean createBean(ClassLoader cld,
String className,
Class[] argTypes,
Object[] args)
throws ClassNotFoundException,
NoSuchMethodException,
InstantiationException,
IllegalAccessException,
IllegalArgumentException,
InvocationTargetException,
IOException
Create a bean using given class loader and using the appropriate
constructor for the given args of the given arg types.
cld
- the class loader to use. If null, Class.forName is used.className
- name of class to instantiateargTypes
- array of argument typesargs
- array of arguments
createBean
public static Bean createBean(ClassLoader cld,
String className,
Object[] args)
throws ClassNotFoundException,
NoSuchMethodException,
InstantiationException,
IllegalAccessException,
IllegalArgumentException,
InvocationTargetException,
IOException
Create a bean using given class loader and using the appropriate
constructor for the given args. Figures out the arg types and
calls above.
cld
- the class loader to use. If null, Class.forName is used.className
- name of class to instantiateargs
- array of arguments
getField
public static Bean getField(Object target,
String fieldName)
throws IllegalArgumentException,
IllegalAccessException
getProperty
public static Bean getProperty(Object target,
String propName,
Integer index)
throws IntrospectionException,
IllegalArgumentException,
IllegalAccessException,
InvocationTargetException
Get a property of a bean.
target
- the object whose prop is to be gottenpropName
- name of the property to setindex
- index to get (if property is indexed)
setField
public static void setField(Object target,
String fieldName,
Bean value,
TypeConvertorRegistry tcr)
throws IllegalArgumentException,
IllegalAccessException
setProperty
public static void setProperty(Object target,
String propName,
Integer index,
Object value,
Class valueType,
TypeConvertorRegistry tcr)
throws IntrospectionException,
IllegalArgumentException,
IllegalAccessException,
InvocationTargetException
Set a property of a bean to a given value.
target
- the object whose prop is to be setpropName
- name of the property to setindex
- index to set (if property is indexed)value
- the property valuevalueType
- the type of the above (needed when its null)tcr
- type convertor registry to use to convert value type to
property type if necessary