Basic Bean Concepts
JavaBeans, regardless of their functionality, are defined by the following features.
· Introspection —Beans support introspection, which allows a builder tool to analyze how Beans work. They adhere to specific rules called design patterns for naming Bean features. Each Bean has a related Bean information class, which provides property, method, and event information about the Bean itself. Each Bean information class implements a BeanInfo interface, which explicitly lists the Bean features that are to be exposed to application builder tools.
· Properties —Properties control a Bean's appearance and behavior. Builder tools introspect on a Bean to discover its properties and to expose them for manipulation. As a result, you can change a Bean's property at design time.
· Customization —The exposed properties of a Bean can be customized at design time. Customization allows a user to alter the appearance and behavior of a Bean. Beans support customization by using property editors or by using special, sophisticated Bean customizers.
· Events —Beans use events to communicate with other Beans. Beans may fire events, which means the Bean sends an event to another Bean. When a Bean fires an event it is considered a source Bean. A Bean may receive an event, in which case it is considered a listener Bean. A listener Bean registers its interest in the event with the source Bean. Builder tools use introspection to determine those events that a Bean sends and those events that it receives.
· Persistence —Beans use Java object serialization, implementing the java.io.Serializable interface, to save and restore state that may have changed as a result of customization. State is saved, for example, when you customize a Bean in an application builder, so that the changed properties can be restored at a later time.
· Methods —All JavaBean methods are identical to methods of other Java classes. Bean methods can be called by other Beans or via scripting languages. A JavaBean public method is exported by default.
While Beans are intended to be used primarily with builder tools, they need not be. Beans can be manually manipulated by text tools through programmatic interfaces. All key APIs, including support for events, properties, and persistence, are designed to be easily read and understood by programmers, as well as by builder tools.