Class WrapDynaClass

java.lang.Object
org.apache.commons.beanutils2.WrapDynaClass
All Implemented Interfaces:
DynaClass

public class WrapDynaClass extends Object implements DynaClass
Implements 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 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 the descriptors list.
    • properties

      protected DynaProperty[] 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 the properties list.
  • Method Details

    • clear

      public static void clear()
      Clear our cache of WrapDynaClass instances.
    • createDynaClass

      public static WrapDynaClass createDynaClass(Class<?> beanClass)
      Create (if necessary) and return a new WrapDynaClass instance for the specified bean class.
      Parameters:
      beanClass - Bean class for which a WrapDynaClass is requested
      Returns:
      A new Wrap DynaClass
    • createDynaClass

      public 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. 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.
      Parameters:
      beanClass - Bean class for which a WrapDynaClass is requested
      pu - the optional PropertyUtilsBean to be used for introspection
      Returns:
      A new Wrap DynaClass
      Since:
      1.9
    • getBeanClass

      protected Class<?> 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 interface DynaClass
      Returns:
      the set of properties for this DynaClass
    • getDynaProperty

      Gets a property descriptor for the specified property, if it exists; otherwise, return null.
      Specified by:
      getDynaProperty in interface DynaClass
      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

      public String getName()
      Gets the name of this DynaClass (analogous to the getName() method of Class, which allows the same DynaClass implementation class to support different dynamic classes, with different sets of properties.
      Specified by:
      getName in interface DynaClass
      Returns:
      the name of the DynaClass
    • getPropertyDescriptor

      Gets the PropertyDescriptor for the specified property name, if any; otherwise return null.
      Parameters:
      name - Name of the property to be retrieved
      Returns:
      The descriptor for the specified property
    • getPropertyUtilsBean

      Returns the PropertyUtilsBean instance associated with this class. This bean is used for introspection.
      Returns:
      the associated PropertyUtilsBean instance
      Since:
      1.9
    • introspect

      protected void 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 interface DynaClass
      Returns:
      A new DynaBean instance
      Throws:
      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 reason