Implementing a statemanager – Pitney Bowes MapXtreme User Manual

Page 117

Advertising
background image

Chapter 6: Understanding State Management

A Detailed Look at Manual State Management

MapXtreme v7.1

117

Developer Guide

MapInfo.Engine.Session.Pooled: Because this key has a value of "true", MapXtreme Session
objects are pooled by the COM+ service. When a new MapXtreme Session is retrieved upon a
new client request, the Session could be "clean" - a new object just created - or it could be a
"dirty" object which has already been used to handle a previous request. Because of the
uncertain state of this object, this application will take steps within each request to restore the
MapXtreme Session to a known state before using it.

MapInfo.Engine.Session.State: Because this key has a value of "Manual", the application is
responsible for explicitly saving and restoring Session state. The Manual setting aids
performance, because the application's StateManager class is written with intelligence about
which objects it should save and restore. The StateManager selectively saves and restores only
the minimum number of objects that are needed; that is why it is the most efficient state
management option. (See

Implementing a StateManager on page 122

).

MapInfo.Engine.Session.Workspace: This setting lets you specify a semi-colon separated list
of.mws workspace files, which will be pre-loaded at the time the MapXtreme Session is created.
To specify multiple workspaces, separate the filenames with semi-colons.

Farther down in the Web.config file, you will find this setting:

<sessionState mode="StateServer"
stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data
source=127.0.0.1;user id=sa;password=" cookieless="false" timeout="20" />

This indicates how you wish to save state; in this case, to the StateServer where the information can
be retrieved at a later time. You can also set this to SQLServer, where state is saved to a database.

Implementing a StateManager

The Thematic sample application uses manual state management, which means it requires an
implementation of a StateManager class to save and restore the appropriate MapXtreme Session
changes.

This class inherits from the abstract base class MapInfo.WebControls.StateManager and must
implement the following methods:

Public Overrides Sub RestoreState()
Public Overrides Sub SaveState()

L

If you use the " template to create a new web site in Visual Studio, the resulting project
includes an implementation of the StateManager, called AppStateManager.

The exact contents of the AppStateManager class vary from application to application. The more
options your application provides, allowing the user to customize the map, the more code you need
to add to the AppStateManager, to save and restore those customizations. This is why the
AppStateManager that is provided with the Thematics sample application contains more code than
the AppStateManager that you get when you create a new project from the MapXtreme Web Site
template.

For example, the thematic sample handles customizations to theme layers, theme tables, attribute
tables, and a group layer. The web template, in contrast, has code to handle customizations to
layers and selections.

Advertising