Manual state management: a walk-through – Pitney Bowes MapXtreme User Manual

Page 113

Advertising
background image

Chapter 6: Understanding State Management

State Management For Pooled Objects

MapXtreme v7.1

113

Developer Guide

There are four possible beginning states that your application must handle. Each situation involves a
user condition and a MapXtreme Session state.

Manual State Management: A Walk-Through

An example helps to illustrate how pooled MapXtreme Sessions are managed when an application
uses the manual state management model. The following describes, in simplified terms, a possible
sequence of events:

1. A user launches a browser and goes to your mapping application web site.

2. Since this application uses pooling, a MapXtreme Session instance is retrieved from the pool.

3. The RestoreState method is called from Page_Load.

If the MapXtreme Session is "dirty," with some user’s changes, the application sets the map back
to the desired beginning state; see the RestoreDefaultState method in the AppStateManager
class.
For this example, let us assume that the beginning state shows a map of the entire world.

4. The web page's HTML is rendered and returned to the client browser. Part of the page is an

HTML img tag, which requests an image of the map from the server. On the server, objects from
this user's browser session—a Map object, in particular—are used to render the map image,
which is returned to the user's browser.

5. In the Page_Unload method, the application saves the user's state, by calling the

AppStateManager.SaveState method.

6. The user selects the Zoom In tool and draws a marquee box around Australia. Javascript that is

built into the Zoom In tool submits a request to the server to zoom in on Australia.

7. On the MapXtreme server, the application once again must fetch a MapXtreme Session object

from the pool. Note that the MapXtreme Session returned from the pool may be a different object
than was used to service the previous request. This object could be clean or dirty.

8. On the server the application calls the AppStateManager.RestoreState method, to restore the

user state that was saved in

step 4

. This restores the MapXtreme Session to a known state that

is appropriate for this user.

User is...

MapXtreme Session in the Pool is....

New to the site

Clean

*

*

MapXtreme Session and its background map are in their initial state.

New to the site

Dirty

MapXtreme Session and/or its background map contain another user's changes.

Returning to the site

Clean

*

Returning to the site

Dirty

Advertising