Chapter 3. JavaBeans

Introduction

Beans are everywhere, popping up in web-application frameworks, enterprise applications, Swing Graphical User Interface (GUIs), templating engines, and object-relational mapping (ORM) tools. Most systems have some sort of object model; for example, an electronic commerce application would have an object model involving an Invoice, which relates to a Customer; or a sports news web site would have related Athlete, Sport, and Team objects. Frequently, objects in these object models are beans—simple objects with properties, encapsulating access to these properties via public getter and setter methods.

In 1997, Sun Microsystems published Version 1.01 of the JavaBeans© specification. Initially, Sun offered beans as visual components for graphical user interfaces; JavaBeans were to be the equivalent of Microsoft’s ActiveX controls—a framework and set of interfaces for creating reusable and pluggable GUI components. Used as components, which exposed states through a series of accessor and mutator (getX( ) and setX()) methods, a developer would develop a GUI Java application by creating a visual layout using an IDE like Visual Cafe or JBuilder. If you’ve ever developed with Microsoft tools, you’ll know exactly what this means—Java was going to unseat Visual Basic, and GUI development was going to be easier than easy. According to the JavaBeans Specification Version 1.01 from 1997:

A Java Bean is a reusable software component that can be manipulated visually ...

Get Jakarta Commons Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.