Chapter 5. Persistence

Most components maintain information that defines their appearance and behavior. This information is known as the state of the object. Some of this information is represented by the object’s properties. For instance, the font or color properties of a visual component are usually considered to be part of that object’s state. The Thermometer class that we’ve been discussing in previous chapters has a MinimumTemperature property that is part of its state. There may also be internal data used by an object that is not exposed as properties, but plays a part in defining the behavior of the object nevertheless.

An applet or application may use one or more components, and these components will be configured to exhibit specific behavior. When the application is loaded, these components should automatically exhibit the prescribed behavior. This means that the state information of all of the components, as well as the application or applet itself, must be saved on a persistent storage medium so that it can be used to recreate the overall application state at run-time. Figure 5.1 shows that some portion of an application will be saved to, and subsequently restored from, persistent storage. An important aspect of application state is the definition of the components themselves: the persistent state of an application includes a description of the components being used, as well as their collective state.

Figure 5-1. Saving and restoring components

The JavaBeans architecture ...

Get Developing Java Beans now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.