JavaBeans Concepts and the Beans Development Kit |
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. A "JavaBeans-enabled" 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:
- 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:
See Chapter 8 of the JavaBeans API Specification for an introspection, design pattern, and
- By adhering to specific naming conventions, known as design patterns, when naming Bean features. The
java.beans.Introspector
class examines Beans for these design patterns to discover Bean features. TheIntrospector
class relies on the core reflection API.
- By explicity providing property, method, and event information with a related Bean Information class. A Bean information class implements the
BeanInfo
interface. ABeanInfo
class explicitly lists those Bean features that are to be exposed to application builder tools.BeanInfo
discussion.
- Properties are a Bean's appearance and behavior characteristics that can be changed at design time. Properties are exposed to builder tools by design patterns or a
BeanInfo
class. See Chapter 7 of the JavaBeans API Specification for a complete property discussion.
- 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. See Chapter 9 of the JavaBeans API Specification for a customization discussion.
- 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). See Chapter 6 of the JavaBeans API Specification for a complete event discussion.
- Persistence enables Beans to save their state, and restore that state later. Once you've changed a Beans properties, you can save the state of the Bean and restore that Bean at a later time. JavaBeans uses Java Object Serialization to support persistence. See Chapter 5 of the JavaBeans API Specification for a persistence discussion.
- A Bean's methods are no different than Java methods, and can be called from other Beans or a scripting environment. By default a 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.
JavaBeans Concepts and the Beans Development Kit |