public class WrapDynaClass extends Object implements DynaClass
DynaClass that 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);
| Modifier and Type | Field and Description |
|---|---|
protected PropertyDescriptor[] |
descriptors
The set of PropertyDescriptors for this bean class.
|
protected HashMap<String,PropertyDescriptor> |
descriptorsMap
The set of PropertyDescriptors for this bean class, keyed by the
property name.
|
protected DynaProperty[] |
properties
The set of dynamic properties that are part of this DynaClass.
|
protected HashMap<String,DynaProperty> |
propertiesMap
The set of dynamic properties that are part of this DynaClass,
keyed by the property name.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
clear()
Clear our cache of WrapDynaClass instances.
|
static WrapDynaClass |
createDynaClass(Class<?> beanClass)
Create (if necessary) and return a new
WrapDynaClass
instance for the specified bean class. |
static WrapDynaClass |
createDynaClass(Class<?> beanClass,
PropertyUtilsBean pu)
Create (if necessary) and return a new
WrapDynaClass instance
for the specified bean class using the given PropertyUtilsBean
instance for introspection. |
protected Class<?> |
getBeanClass()
Return the class of the underlying wrapped bean.
|
DynaProperty[] |
getDynaProperties()
Return an array of
ProperyDescriptors for the properties
currently defined in this DynaClass. |
DynaProperty |
getDynaProperty(String name)
Return a property descriptor for the specified property, if it exists;
otherwise, return
null. |
String |
getName()
Return the name of this DynaClass (analogous to the
getName() method of java.lang.Class, which
allows the same DynaClass implementation class to support
different dynamic classes, with different sets of properties. |
PropertyDescriptor |
getPropertyDescriptor(String name)
Return the PropertyDescriptor for the specified property name, if any;
otherwise return
null. |
protected PropertyUtilsBean |
getPropertyUtilsBean()
Returns the
PropertyUtilsBean instance associated with this class. |
protected void |
introspect()
Introspect our bean class to identify the supported properties.
|
DynaBean |
newInstance()
Instantiates a new standard JavaBean instance associated with
this DynaClass and return it wrapped in a new WrapDynaBean
instance.
|
protected PropertyDescriptor[] descriptors
protected HashMap<String,PropertyDescriptor> descriptorsMap
descriptors list.protected DynaProperty[] properties
protected HashMap<String,DynaProperty> propertiesMap
properties list.protected Class<?> getBeanClass()
public String getName()
getName() method of java.lang.Class, which
allows the same DynaClass implementation class to support
different dynamic classes, with different sets of properties.public DynaProperty getDynaProperty(String name)
null.getDynaProperty in interface DynaClassname - Name of the dynamic property for which a descriptor
is requestedIllegalArgumentException - if no property name is specifiedpublic DynaProperty[] getDynaProperties()
Return an array of ProperyDescriptors 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?
getDynaProperties in interface DynaClasspublic DynaBean newInstance() throws IllegalAccessException, InstantiationException
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.)
newInstance in interface DynaClassDynaBean instanceIllegalAccessException - 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 reasonpublic PropertyDescriptor getPropertyDescriptor(String name)
null.name - Name of the property to be retrievedpublic static void clear()
public static WrapDynaClass createDynaClass(Class<?> beanClass)
WrapDynaClass
instance for the specified bean class.beanClass - Bean class for which a WrapDynaClass is requestedDynaClasspublic static WrapDynaClass createDynaClass(Class<?> beanClass, PropertyUtilsBean pu)
WrapDynaClass instance
for the specified bean class using the given PropertyUtilsBean
instance for introspection. Using this method a specially configured
PropertyUtilsBean instance can be hooked into the introspection
mechanism of the managed bean. The argument is optional; if no
PropertyUtilsBean object is provided, the default instance is used.beanClass - Bean class for which a WrapDynaClass is requestedpu - the optional PropertyUtilsBean to be used for introspectionDynaClassprotected PropertyUtilsBean getPropertyUtilsBean()
PropertyUtilsBean instance associated with this class. This
bean is used for introspection.PropertyUtilsBean instanceprotected void introspect()
Copyright © 2000–2019 The Apache Software Foundation. All rights reserved.