Java Reference
In-Depth Information
Session
Pattern Properties
Type: Processing
Level: Architectural
Purpose
To provide a way for servers in distributed systems to distinguish among clients, allowing applications to
associate state with the client-server communication.
Introduction
In a networked Personal Information Manager, it's likely that you want to centralize some of the information, like
a company's customers.
Clients would need to routinely update contact information on the server, and the updates might occur over
several stages. Users might modify information about the contact's position and company, then modify contact
addresses. Since there can be any number of address updates, and users can potentially be entering the
information in real time, you decide to allow the client to submit the changes over multiple interactions with the
server.
This brings up a problem—how do you track a user's changes that relate to a specific contact, when these changes
take place in stages? Multiple clients will be making updates at the same time, and the server will need to know
which updates come from which clients. Otherwise, one client might update the wrong customer record.
The most efficient approach is to associate a temporary identity with each user, so that the server can keep better
track of workflow. When a user begins to edit information on the server, the server starts a session, issuing it a
session ID. Each time the user performs an edit, such as adding or removing an address, the user's application
sends the session's ID to the server. When the contact information has been updated, the application the user is
using sends a finalize message to the server to indicate that the client is done updating that contact information.
The server then ends the session.
This solution, also known as the Session pattern, provides a number of benefits to the server. It provides the server with a way to
differentiate among clients, and to keep track of a particular client's progress in workflow. Finally, it allows the server to store
information that is in flux, instead of storing the information on the client. With a session, the server can cache the user's information in
memory until the user has completed the edits.
Applicability
The Session pattern is appropriate for client-server or peer-to-peer systems with the following requirement:
Client identity - You need some way to distinguish among callers in a multiuser system.
Additionally, Session is normally used for systems with one or both of the following characteristics:
Operation continuity - You want to be able to associate specified operations with each other in the system.
Operations might follow a transactional or a workflow model.
Data persistence - You need to associate data with the client over the time that the client interacts with the
server.
Description
Information about the Session pattern is divided into the following sections.
Stateful and Stateless Communication
Communication between distributed systems can be stateful or stateless.
 
Search WWH ::




Custom Search