|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.beanutils.WrapDynaClass
public class WrapDynaClass
Implementation of DynaClass
for DynaBeans that wrap
standard JavaBean instances.
It is suggested that this class should not usually need to be used directly
to create new WrapDynaBean
instances.
It's usually better to call the WrapDynaBean
constructor directly.
For example:
Object javaBean = ...;
DynaBean wrapper = new WrapDynaBean(javaBean);
Field Summary | |
---|---|
protected Class |
beanClass
Deprecated. No longer initialized, use getBeanClass() method instead |
protected PropertyDescriptor[] |
descriptors
The set of PropertyDescriptors for this bean class. |
protected HashMap |
descriptorsMap
The set of PropertyDescriptors for this bean class, keyed by the property name. |
protected static HashMap |
dynaClasses
Deprecated. The dynaClasses Map will be removed in a subsequent release |
protected DynaProperty[] |
properties
The set of dynamic properties that are part of this DynaClass. |
protected HashMap |
propertiesMap
The set of dynamic properties that are part of this DynaClass, keyed by the property name. |
Method Summary | |
---|---|
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. |
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 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 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Class beanClass
Class
which is represented by this
WrapDynaClass
.
protected PropertyDescriptor[] descriptors
protected HashMap descriptorsMap
descriptors
list.
protected DynaProperty[] properties
protected HashMap propertiesMap
properties
list.
protected static HashMap dynaClasses
WrapDynaClass
instances that have ever been
created, keyed by the underlying bean Class. The keys to this map
are Class objects, and the values are corresponding WrapDynaClass
objects.
This static variable is safe even when this code is deployed via a shared classloader because it is keyed via a Class object. The same class loaded via two different classloaders will result in different entries in this map.
Note, however, that this HashMap can result in a memory leak. When this class is in a shared classloader it will retain references to classes loaded via a webapp classloader even after the webapp has been undeployed. That will prevent the entire classloader and all the classes it refers to and all their static members from being freed. !!!!!!!!!!!! PLEASE NOTE !!!!!!!!!!!! ************* THE FOLLOWING IS A NASTY HACK TO SO THAT BEANUTILS REMAINS BINARY COMPATIBLE WITH PREVIOUS RELEASES. There are two issues here: 1) Memory Issues: The static HashMap caused memory problems (See BEANUTILS-59) to resolve this it has been moved into a ContextClassLoaderLocal instance (named CLASSLOADER_CACHE above) which holds one copy per ClassLoader in a WeakHashMap. 2) Binary Compatibility: As the "dynaClasses" static HashMap is "protected" removing it breaks BeanUtils binary compatibility with previous versions. To resolve this all the methods have been overriden to delegate to the Map for the ClassLoader in the ContextClassLoaderLocal.
Method Detail |
---|
protected Class getBeanClass()
public String getName()
getName()
method of java.lang.Class
DynaClass implementation class to support
different dynamic classes, with different sets of properties.
getName
in interface DynaClass
public DynaProperty getDynaProperty(String name)
null
.
getDynaProperty
in interface DynaClass
name
- Name of the dynamic property for which a descriptor
is requested
IllegalArgumentException
- 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 DynaClass
public 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 newWrapDynaBean
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 DynaClass
DynaBean
instance
IllegalAccessException
- if the Class or the appropriate
constructor is not accessible
InstantiationException
- 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 retrieved
public static void clear()
public static WrapDynaClass createDynaClass(Class beanClass)
WrapDynaClass
instance for the specified bean class.
beanClass
- Bean class for which a WrapDynaClass is requested
DynaClass
protected void introspect()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |