Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Applied Java™ Patterns - Stephen Stelting, Olav Maassen.pdf
Скачиваний:
202
Добавлен:
24.05.2014
Размер:
2.84 Mб
Скачать

Successive Update

Also known as Client Pull / Server Push

Pattern Properties

Type: Processing (Behavioral)

Level: Architectural

Purpose

To provide a way for clients to receive updates from a server on an ongoing basis. The updates generally reflect a change in server data, a new or updated resource, or a change in the state of the business model.

Introduction

Suppose you wanted to use the Personal Information Manager as a way to coordinate work between multiple users. For example, you could enable multiple users to share information about the part of the project that they were currently working on. If you subdivided a project into Task and Deliverable objects, you might want to allow interested users (such as the project manager) to get updates on the progress of one or more Tasks.

If you create a server, it is straightforward to centralize the project information—you would simply store the Project, Task and Deliverable objects on the server. But how should you manage the task of keeping the clients up to date?

You can follow two strategies, each of which is a form of the Successive Update pattern. Make the client responsible for regularly querying the server, requesting updates on a Task; or alternatively, make the server responsible for sending Task updates out to clients.

In both cases, you expand the role of server and enable a groupware-style solution. You can send periodic updates to clients and ensure that they are coordinated in the work that they do.

Applicability

Use Successive Update for client-server systems when:

Server-side resources or data are in flux, changing due to interactions with multiple clients or external updates.

You want a client to receive updates without forcing the user to do a manual refresh.

Description

Successive Update is used for applications that require an ongoing refresh of the client’s state. While it is possible to manually update the data, it is tedious and frustrating for an end user who must frequently refresh information— imagine having to manually send a request to your server every minute that you used an application. Although such a system might gives its users strong, muscular fingers, overall it would probably not be popular in conventional IT businesses.

To provide an acceptable alternative, Successive Update automates what users would otherwise have to do manually. The client and server establish an automatic update strategy, eliminating the need for the user to become directly involved. You can implement Successive Update using a variety of approaches, but it is frequently associated with two techniques at two ends of a spectrum— client pull and server push.

Client Pull

Client pull schedules a periodic refresh of information that is managed on the client side. The server performs its normal task, providing information when requested by its clients. Client pull is essentially a regular series of requests for server information.

A Successive Update sequence diagram for client pull is shown in Figure 4.8.

Figure 4.8. Successive Update sequence diagram (client pull)

167