What Distinguishes JavaBeans from Widgets?
JavaBeans
define a design-time interface. This interface allows application designer
tools, or builder tools, to query components to determine the kinds of
properties the components define and the kinds of events they generate or to
which they respond.
In
visual application builder environments, Beans are sometimes referred to as
reusable software components or custom controls. Software components such as
JavaBeans are packaged differently from standard Windows controls or Motif
widgets. They are packaged with design-time information (properties and methods)
that allow builder tools to determine their capabilities.
In
addition, end users, or third party suppliers, can build custom beans
independently of the GUI platform or operating system. IS departments can
distribute these third-party components to internal enterprise clients, or they
can be sold as add-on components to anyone who uses builder tools to construct
applications.
What Distinguishes JavaBeans
from Java Classes?
Any
Java class that adheres to certain conventions regarding property and event
interface definitions can be a JavaBean. Beans are Java classes that can be
manipulated in a visual builder tool and composed into applications.
Introspection,
the process by which a builder tool analyzes how a Bean works, differentiates
Beans from typical Java classes. Because Beans are coded with predefined
patterns for their method signatures and class definitions, tools that recognize
these patterns can "look inside" a Bean and determine its properties
and behavior.
Introspection
allows a Bean's state to be manipulated at design time—that is, at the time it
is being assembled as a part within a larger application. For this to work,
method signatures within Beans must follow a certain pattern so that
introspection tools recognize how Beans can be manipulated, both at design time
and at run time.
In
effect, Beans publish their attributes and behaviors through special method
signature patterns that are recognized by beans-aware application construction
tools. However, these construction tools are not required to build or test your
beans. The pattern signatures are easily recognized by human readers, as well as
builder tools. One of the first things you'll learn when building beans is how
to recognize and construct methods that adhere to these patterns.
Beans
should not be used indiscriminately. Beans are best suited to software
components intended to be visually manipulated within builder tools. Some
functionality, such as the JDBCTM API, is still best provided through
a programmatic or textual interface, rather than a visual manipulation
interface.
Basic Bean Concepts
JavaBeans, regardless of their functionality, are defined by the
following features.
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.
For your
first JavaBean, let's look at the BDK BeanBox. Although in this tutorial we use
the BeanBox to create a JavaBean, the BeanBox is generally used to test your
JavaBeans. The BeanBox is considered a reference builder tool environment. It is
not designed for building GUI applications, nor is it meant to have a look and
feel of such other builder tools as Visual Age, Delphi, or Visual Basic.