Name

Asynchronous Page

Goal

Cache remote data as it is generated.

Participants

Publishers

Remote entities that generate new data at some interval. May also notify subscribers when new data is available.

Subscriber

A singleton object responsible for retrieving, formatting, and caching remote data either as it is generated or at some interval.

Models

Store state data for applications.

Views

When requests are received, translate model data into a format appropriate for display to the user (Figure A-12).

Interactions in the Asynchronous Page pattern
Figure A-12. Interactions in the Asynchronous Page pattern

Interactions

The subscriber retrieves data from the publisher either when it has changed or at some predefined interval. The subscriber processes the data and updates all appropriate models. When requests are received, the view translates current model data into a format suitable for the user.

Notes

The most effective use of this pattern is when a single subscriber downloads dynamic data and uses it to generate static HTML pages on each web server. It is also useful in situations where multiple web servers use separate data models that must be kept up to date.

Get J2EE Design Patterns 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.