10.9 Naming Patterns and ConventionsAs we've seen, beanbox programs may rely on introspection of a bean to determine the list of properties, events, and methods it supports. In order for this to work, bean developers must follow a set of standard naming conventions, sometimes referred to as JavaBeans "design patterns." These patterns specify, for example, that the getter and setter accessor methods for a property should begin with get and set. Not all of the patterns are absolute requirements. If a bean has accessor methods with different names, it is possible to use a PropertyDescriptor object, specified in a BeanInfo class, to specify the accessor methods for the property. Note, however, that although an accessor method name is not required to follow the pattern, the method is required to have the exact type signature specified by the pattern. This section lists the design patterns for bean properties, events, and methods. It also lists other conventions and requirements that you should keep in mind when developing beans. Java Bean PatternsBeans
Properties (property p of type T)
Boolean Properties (property p of type boolean)
Indexed Properties (property p of type T[])
Bound Properties (property p of type T)
Constrained Properties (property p of type T)
Events (event named E)
Unicast Events (event named E only one listener allowed)
Methods
BeanInfo Classes (for bean B)
Property Editors (for properties of type T)
Property Editors (for individual properties)
Customizers (for bean B)
Documentation File (for bean B)
|
|