Naming a BeanInfo Class

The naming of a BeanInfo class uses a design pattern of its own. The name of the class is a concatenation of the class name for the Bean with the string BeanInfo. So if you have a Bean class named Xyz, its BeanInfo class must be named XyzBeanInfo. Normally, the BeanInfo class belongs to the same package as the Bean class it describes, but this is not a firm requirement. When a BeanInfo class is being located, the package path for the associated Bean class is searched first; so for Bean Package.Xyz, the class Package.XyzBeanInfo is looked for first. If this class is not found, the XyzBeanInfo class is searched for in the packages specified by the BeanInfo package search path. This search path can be accessed using the getBeanInfoSearchPath() and setBeanInfoSearchPath() methods of the java.beans.Instrospector class.

Get Developing Java Beans now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.