Method and System for Logical Session Partitioning in a Multi-tasking Web Application
Original Publication Date: 2005-Mar-07
Included in the Prior Art Database: 2005-Mar-07
A web application typically maintains user state within a session object. As a user navigates within an application, different components in that application store and retrieve data from the session object. Having a single session object creates complications for multi-tasking web applications, in which users can launch and switch between concurrent tasks. The primary problem is that there cannot be overlap in the session data identifiers between two or more concurrent tasks. Overlap in the session data identifiers can lead to incorrect functionality if one task overwrites the data being used by another task. A solution is to logically partition the session so that session identifiers used in one task can never overlap with the session identifiers of another task. To accomplish this, put a wrapper around the session object and give each task a unique identifier. All components in the web application only access the session through the wrapper. The wrapper always appends the unique identifier of the currently active task to the session identifier of data accessed in the session. As a result, the appended task identifier ensures that the session identifiers from one task can never overlap with the session identifiers from another. This technique allows the creation of distinct identifiers to remain entirely transparent to the programmer; the programmer must simply access the session through the wrapper. In effect, the technique eliminates the need for extra consideration and effort with managing session data when developing a web application with multi-tasking capabilities.
Method and System for Logical Session Partitioning in a Multi -tasking Web Application
Disclosed is a method and system for logically partitioning a session object in a multi-tasking web application. First, create a unique identifier for each task launched. Then, for all accesses to data in the session by the components in that task, automatically append the task's identifier to the session identifiers for that data. In order to accomplish this transparently, utilize a SessionWrapper that encapsulates the session object and provides the following:
A field taskId that is the unique identifier for the task that the SessionWrapper is for.
A method putDataInSession(ID id, Data d): Puts the given Data d in the session with the ID id + taskId.
A method getDataFromSession(ID id): Retrieves the data from the session with the ID id + taskId.
A method removeDataFromSession(ID id): Removes the data in the session with the ID id + taskId.
When a task is a launched, create taskId and a new SessionWrapper for the task. The SessionWrapper stores taskId. Whenever any component needs to access data in the session, it first obtains the SessionWrapper for the current task. All accesses to data in the session are then performed through the SessionWrapper.
This solution requires that taskId be unique across all tasks. Creation of taskId can be as simple as maintaining a counter that is incremented each time a task is launched (as long as the number of potentially concurrent task inst...