JavaBeans Component Design Conventions

JavaBeans component design conventions govern the properties of the class, and govern the public methods that give access to the properties.

A JavaBeans component property can be

  • Read/write, read-only, or write-only

  • Simple, which means it contains a single value, or indexed, which means it represents an array of values

There is no requirement that a property be implemented by an instance variable; the property must simply be accessible using public methods that conform to certain conventions:

  • For each readable property, the bean must have a method of the form PropertyClass getProperty() { ... }

  • For each writable property, the bean must have a method of the form setProperty(PropertyClass pc) { ... }

In addition ...

Get J2EE™ Tutorial, The 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.