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
Modifier 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 void
clear()
Clear our cache of WrapDynaClass instances.static WrapDynaClass
createDynaClass
(Class<?> beanClass) Create (if necessary) and return a newWrapDynaClass
instance for the specified bean class.static WrapDynaClass
createDynaClass
(Class<?> beanClass, PropertyUtilsBean pu) Create (if necessary) and return a newWrapDynaClass
instance for the specified bean class using the givenPropertyUtilsBean
instance for introspection.protected Class<?>
Gets the class of the underlying wrapped bean.Return an array ofPropertyDescriptor
for 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 sameDynaClass
implementation 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 PropertyUtilsBean
Returns thePropertyUtilsBean
instance associated with this class.protected void
Introspect 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 thedescriptors
list. -
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 theproperties
list.
-
-
Method Details
-
clear
Clear our cache of WrapDynaClass instances. -
createDynaClass
Create (if necessary) and return a newWrapDynaClass
instance 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 newWrapDynaClass
instance for the specified bean class using the givenPropertyUtilsBean
instance for introspection. Using this method a specially configuredPropertyUtilsBean
instance can be hooked into the introspection mechanism of the managed bean. The argument is optional; if noPropertyUtilsBean
object is provided, the default instance is used.- Parameters:
beanClass
- Bean class for which a WrapDynaClass is requestedpu
- the optionalPropertyUtilsBean
to 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
PropertyDescriptor
for 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:
getDynaProperties
in 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:
getDynaProperty
in 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 sameDynaClass
implementation 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 thePropertyUtilsBean
instance associated with this class. This bean is used for introspection.- Returns:
- the associated
PropertyUtilsBean
instance - 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
WrapDynaBean
instances by calling its constructor. For example:Object javaBean = ...; DynaBean wrapper = new WrapDynaBean(javaBean);
(This method is needed for some kinds of
DynaBean
framework.)- Specified by:
newInstance
in interfaceDynaClass
- Returns:
- A new
DynaBean
instance - 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
-