Class WrapDynaClass
- All Implemented Interfaces:
DynaClass
DynaClass to wrap standard JavaBean instances.
This class should not usually need to be used directly to create new WrapDynaBean instances - it's usually better to call the WrapDynaBean
constructor. For example:
Object javaBean = ...; DynaBean wrapper = new WrapDynaBean(javaBean);
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HashMap<String, PropertyDescriptor> The set of PropertyDescriptors for this bean class, keyed by the property name.protected DynaProperty[]The set of dynamic properties that are part of this DynaClass.protected HashMap<String, DynaProperty> The set of dynamic properties that are part of this DynaClass, keyed by the property name. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()Clear our cache of WrapDynaClass instances.static WrapDynaClasscreateDynaClass(Class<?> beanClass) Create (if necessary) and return a newWrapDynaClassinstance for the specified bean class.static WrapDynaClasscreateDynaClass(Class<?> beanClass, PropertyUtilsBean pu) Create (if necessary) and return a newWrapDynaClassinstance for the specified bean class using the givenPropertyUtilsBeaninstance for introspection.protected Class<?> Gets the class of the underlying wrapped bean.Return an array ofPropertyDescriptorfor the properties currently defined in this DynaClass.getDynaProperty(String name) Gets a property descriptor for the specified property, if it exists; otherwise, returnnull.getName()Gets the name of this DynaClass (analogous to thegetName()method ofClass, which allows the sameDynaClassimplementation class to support different dynamic classes, with different sets of properties.getPropertyDescriptor(String name) Gets the PropertyDescriptor for the specified property name, if any; otherwise returnnull.protected PropertyUtilsBeanReturns thePropertyUtilsBeaninstance associated with this class.protected voidIntrospect our bean class to identify the supported properties.Instantiates a new standard JavaBean instance associated with this DynaClass and return it wrapped in a new WrapDynaBean instance.
-
Field Details
-
descriptorsMap
The set of PropertyDescriptors for this bean class, keyed by the property name. Individual descriptor instances will be the same instances as those in thedescriptorslist. -
properties
The set of dynamic properties that are part of this DynaClass. -
propertiesMap
The set of dynamic properties that are part of this DynaClass, keyed by the property name. Individual descriptor instances will be the same instances as those in thepropertieslist.
-
-
Method Details
-
clear
Clear our cache of WrapDynaClass instances. -
createDynaClass
Create (if necessary) and return a newWrapDynaClassinstance for the specified bean class.- Parameters:
beanClass- Bean class for which a WrapDynaClass is requested- Returns:
- A new Wrap
DynaClass
-
createDynaClass
Create (if necessary) and return a newWrapDynaClassinstance for the specified bean class using the givenPropertyUtilsBeaninstance for introspection. Using this method a specially configuredPropertyUtilsBeaninstance can be hooked into the introspection mechanism of the managed bean. The argument is optional; if noPropertyUtilsBeanobject is provided, the default instance is used.- Parameters:
beanClass- Bean class for which a WrapDynaClass is requestedpu- the optionalPropertyUtilsBeanto be used for introspection- Returns:
- A new Wrap
DynaClass - Since:
- 1.9
-
getBeanClass
Gets the class of the underlying wrapped bean.- Returns:
- the class of the underlying wrapped bean
- Since:
- 1.8.0
-
getDynaProperties
Return an array of
PropertyDescriptorfor the properties currently defined in this DynaClass. If no properties are defined, a zero-length array will be returned.FIXME - Should we really be implementing
getBeanInfo()instead, which returns property descriptors and a bunch of other stuff?- Specified by:
getDynaPropertiesin interfaceDynaClass- Returns:
- the set of properties for this DynaClass
-
getDynaProperty
Gets a property descriptor for the specified property, if it exists; otherwise, returnnull.- Specified by:
getDynaPropertyin interfaceDynaClass- Parameters:
name- Name of the dynamic property for which a descriptor is requested- Returns:
- The descriptor for the specified property
- Throws:
IllegalArgumentException- if no property name is specified
-
getName
Gets the name of this DynaClass (analogous to thegetName()method ofClass, which allows the sameDynaClassimplementation class to support different dynamic classes, with different sets of properties. -
getPropertyDescriptor
Gets the PropertyDescriptor for the specified property name, if any; otherwise returnnull.- Parameters:
name- Name of the property to be retrieved- Returns:
- The descriptor for the specified property
-
getPropertyUtilsBean
Returns thePropertyUtilsBeaninstance associated with this class. This bean is used for introspection.- Returns:
- the associated
PropertyUtilsBeaninstance - Since:
- 1.9
-
introspect
Introspect our bean class to identify the supported properties. -
newInstance
Instantiates a new standard JavaBean instance associated with this DynaClass and return it wrapped in a new WrapDynaBean instance. NOTE the JavaBean should have a no argument constructor.
NOTE - Most common use cases should not need to use this method. It is usually better to create new
WrapDynaBeaninstances by calling its constructor. For example:Object javaBean = ...; DynaBean wrapper = new WrapDynaBean(javaBean);(This method is needed for some kinds of
DynaBeanframework.)- Specified by:
newInstancein interfaceDynaClass- Returns:
- A new
DynaBeaninstance - Throws:
IllegalAccessException- if the Class or the appropriate constructor is not accessibleInstantiationException- if this Class represents an abstract class, an array class, a primitive type, or void; or if instantiation fails for some other reason
-