| java.lang.Object org.apache.bsf.util.ReflectionUtils
ReflectionUtils | public class ReflectionUtils (Code) | | This file is a collection of reflection utilities. There are utilities
for creating beans, getting bean infos, setting/getting properties,
and binding events.
author: Sanjiva Weerawarana author: Joseph Kesselman |
Method Summary | |
public static void | addEventListener(Object source, String eventSetName, EventProcessor processor) Add an event processor as a listener to some event coming out of an
object. | public static Bean | createBean(ClassLoader cld, String className, Class[] argTypes, Object[] args) Create a bean using given class loader and using the appropriate
constructor for the given args of the given arg types.
Parameters: cld - the class loader to use. | public static Bean | createBean(ClassLoader cld, String className, Object[] args) Create a bean using given class loader and using the appropriate
constructor for the given args. | public static Bean | getField(Object target, String fieldName) | public static Bean | getProperty(Object target, String propName, Integer index) Get a property of a bean. | public static void | setField(Object target, String fieldName, Bean value, TypeConvertorRegistry tcr) | public static void | setProperty(Object target, String propName, Integer index, Object value, Class valueType, TypeConvertorRegistry tcr) Set a property of a bean to a given value. |
createBean | public static Bean createBean(ClassLoader cld, String className, Class[] argTypes, Object[] args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IOException(Code) | | Create a bean using given class loader and using the appropriate
constructor for the given args of the given arg types.
Parameters: cld - the class loader to use. If null, Class.forName is used. Parameters: className - name of class to instantiate Parameters: argTypes - array of argument types Parameters: args - array of arguments the newly created bean exception: ClassNotFoundException - if class is not loaded exception: NoSuchMethodException - if constructor can't be found exception: InstantiationException - if class can't be instantiated exception: IllegalAccessException - if class is not accessible exception: IllegalArgumentException - if argument problem exception: InvocationTargetException - if constructor excepted exception: IOException - if I/O error in beans.instantiate |
setProperty | public static void setProperty(Object target, String propName, Integer index, Object value, Class valueType, TypeConvertorRegistry tcr) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException(Code) | | Set a property of a bean to a given value.
Parameters: target - the object whose prop is to be set Parameters: propName - name of the property to set Parameters: index - index to set (if property is indexed) Parameters: value - the property value Parameters: valueType - the type of the above (needed when its null) Parameters: tcr - type convertor registry to use to convert value type toproperty type if necessary exception: IntrospectionException - if unable to introspect exception: IllegalArgumentException - if problems with args: if theproperty is unknown, or if the property is given an indexwhen its not, or if the property is not writeable, or ifthe given value cannot be assigned to the it (type mismatch). exception: IllegalAccessException - if write method is not accessible exception: InvocationTargetException - if write method excepts |
|
|