The atg.beans package also includes a useful interface named DynamicBeanInfo. A DynamicBeanInfo object allows a bean to be queried about what properties are available from the object, as well as other descriptive data about the bean. This is very similar to the standard BeanInfo objects of JavaBeans, except DynamicBeanInfo is based on the instance, not on the class. The DynamicBeanInfo allows user interfaces to show dynamically the available properties of an object.

The DynamicBeanInfo interface has the following methods:

public interface DynamicBeanInfo {
  public DynamicBeanDescriptor getBeanDescriptor();
  public boolean hasProperty(String pPropertyName);
  public String [] getPropertyNames();
  public DynamicPropertyDescriptor getPropertyDescriptor(String pPropertyName);
  public DynamicPropertyDescriptor[] getPropertyDescriptors();
  public boolean isInstance(Object pObj);
  public boolean areInstances(DynamicBeanInfo pDynamicBeanInfo);

DynamicBeanDescriptor is a subclass of the java.beans.FeatureDescriptor class, which includes human-friendly descriptive information about a bean. It includes methods like getName() and getShortDescription(). DynamicPropertyDescriptor is also a subclass of FeatureDescriptor, and allows individual properties of the properties, including a JavaBeans PropertyEditor for the property.

To implement this behavior in a DynamicPropertyMapper, use a getBeanInfo() method. For example, in the MapPropertyMapper discussed earlier, there is a getDynamicBeanInfo method that looks like this:

public DynamicBeanInfo getBeanInfo(Object pBean)
       throws IntrospectionException
    // A Map acts as its own dynamic bean type, since every map
    // is different.
    return DynamicBeans.getBeanInfoFromType(pBean);
loading table of contents...