Bean Introspection  «Prev  Next»
Lesson 8Explicitly providing Bean information
Objective Find out How Beans can Explicitly Provide Information about Themselves.

Find out How JavaBeans can Explicitly Provide Information about Themselves

Although the automatic approach to introspection afforded by applying design patterns is useful and powerful, there may be situations where you want to explicitly provide information about a Bean for introspection purposes.
JavaBeans supports the explicit inclusion of Bean information through Bean information classes.
A Bean information class is a special class that can contain the following information about a Bean:
  1. Description of a Bean
  2. Icons for visually representing the Bean in design tools, toolbars, etc.
  3. Properties of a Bean
  4. Events broadcast by a Bean
  5. Methods supported by a Bean

  1. Properties are the appearance and behavior characteristics of a bean that can be changed at design time
  2. Beans expose properties so they can be customized at design time
  3. Builder tools introspect on a bean to discover its properties and expose those properties for manipulation
  4. Customization is supported in two ways:
1) by using property editors, 2) by using more sophisticated bean customizers
Developing Java Beans
Bean information classes must implement the BeanInfo interface, which defines methods used to determine information about a Bean. A bean's information class must be named the same as the Bean class, with the words BeanInfo appended to the end.
So, if you have a Bean named Widget, then the Bean information class must be named WidgetBeanInfo.


The high-level Introspection APIs only provide information on "public" methods of target beans. The normal JDK security manager will allow even untrusted applets to access public fields and methods using the java.lang.reflect APIs. However, while access to private methods and fields may be available to "trusted" application builders, this access will normally be denied to untrusted applets.