Bean Internals  «Prev  Next»
Lesson 2Structure of a Bean
ObjectiveExplore the structural makeup of a Bean.

Structure of JavaBean

The complexity of some component object models leads developers to often look at software components as mystical entities. JavaBeans, however, holds very little complexity and therefore practically zero mystery. The best way to understand this is to consider the basic structure of a Bean:

Java Beans Technology
Javabean consisting of Data and Methods
Javabean consisting of Data and Methods

A Bean, just like any other object in an object-oriented environment, is comprised of two primary parts:
  1. data and
  2. methods that act on data.
The data part of a Bean completely describes the state of the Bean, while the methods provide a means for the Bean's state to be modified and for actions to be taken accordingly.

What are Components?

Components are self-contained elements of software that can be controlled dynamically and assembled to form applications and these components must also interoperate according to a set of rules and guidelines. They must behave in ways that are expected. The components bring functionality, while the environment brings structure and order.
JavaBeans is Java's component model and allows users to construct applications by piecing components together either programmatically or visually (or both). Support of visual programming is paramount to the component model and is what makes component-based software development truly powerful. The model is made up of an architecture and an API and these elements provide a structure whereby components can be combined to create an application. This environment provides services and rules, the framework that allows components to participate properly. This means that components are provided with the tools necessary to work in the environment, and they exhibit certain behaviors that identify them as such. One very important aspect of this structure is containment and container provides a context in which components can interact. A common example would be a panel that provides layout management or mediation of interactions for visual components. Of course, containers themselves can be components. In the next lesson, you learn about Bean methods.