The JavaTM Tutorial

| Start of Tutorial > Start of Trail > Start of Lesson | Search Feedback Form

Trail: JavaBeans(TM)
Lesson: JavaBeans Concepts and the Beans Development Kit

## JavaBeans Concepts

> The JavaBeans API makes it possible to write component software in the Java programming language. Components are self-contained, reusable software units that can be visually composed into composite components, applets, applications, and servlets using visual application builder tools. JavaBean components are known as Beans.

> Components expose their features (for example, public methods and events) to builder tools for visual manipulation. A Bean's features are exposed because feature names adhere to specific design patterns. A "JavaBeans-enabled" builder tool can then examine the Bean's patterns, discern its features, and expose those features for visual manipulation. A builder tool maintains Beans in a palette or toolbox. You can select a Bean from the toolbox, drop it into a form, modify it's appearance and behavior, define its interaction with other Beans, and compose it and other Beans into an applet, application, or new Bean. All this can be done without writing a line of code.

> The following list briefly describes key Bean concepts, and gives the chapter in the JavaBeans specification where you can read a complete description.

> - Builder tools discover a Bean's features (that is, its properties, methods, and events) by a process known as introspection. Beans support introspection in two ways:
>   - By adhering to specific rules, known as design patterns, when naming Bean features. The `java.beans.Introspector` class examines Beans for these design patterns to discover Bean features. The `Introspector` class relies on the core reflection API. The Reflection API trail is an excellent place to learn about reflection.
>   - By explicity providing property, method, and event information with a related Bean Information class. A Bean information class implements the `BeanInfo` interface. A `BeanInfo` class explicitly lists those Bean features that are to be exposed to application builder tools.
>   Chapter 8 of the JavaBeans API Specification discusses introspection, design patterns, and `BeanInfo` objects.

> - Properties are a Bean's appearance and behavior characteristics that can be changed at design time. Builder tools introspect on a Bean to discover its properties, and expose those properties for manipulation. Chapter 7 of the JavaBeans API Specification discusses properties.

> - Beans expose properties so they can be customized at design time. Customization is supported in two ways: By using property editors, or by using more sophisticated Bean customizers. Chapter 9 of the JavaBeans API Specification discusses Bean customization.

> - Beans use events to communicate with other Beans. A Bean that wants to receive events (a listener Bean) registers its interest with the Bean that fires the event (a source Bean). Builder tools can examine a Bean and determine which events that Bean can fire (send) and which it can handle (receive). Chapter 6 of the JavaBeans API Specification discusses events.

> - Persistence enables Beans to save and restore their state. Once you've changed a Beans properties, you can save the state of the Bean and restore that Bean at a later time, property changes intact. JavaBeans uses Java Object Serialization to support persistence. Chapter 5 of the JavaBeans API Specification discusses persistence.

> - A Bean's methods are no different than Java methods, and can be called from other Beans or a scripting environment. By default all public methods are exported.

> Although Beans are designed to be understood by builder tools, all key APIs, including support for events, properties, and persistence, have been designed to be easily read and understood by human programmers as well.

| Start of Tutorial > Start of Trail > Start of Lesson | Search Feedback Form