Introducing JavaBeans |
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 Beans, applets, applications, and Servlets using visual application builder tools.
JavaBeans is a core JDK1.1 capability: Any JDK1.1-compliant browser or tool implicitly supports JavaBeans.
JavaBean components are called Beans. A "JavaBeans-enabled" builder tool maintains Beans in a palette or toolbox. You can select a particular 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 properties, methods, and events by 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. Bean introspection relies on the core reflection API to discover Bean features via design patterns.
- By explicity providing property, method, and event information with a related Bean Information class. A Bean information class implements the
BeanInfo
interface.BeanInfo
discussion.- Properties are a Bean's appearance and behavior attributes 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. 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.
Beans can be used with both builder tools, or manually manipulated by text tools through programmatic interfaces. All key APIs, including support for events, properties, and persistence, have been designed to be easily read and understood by human programmers as well as by builder tools.
Introducing JavaBeans |