org.itsnat.core
Interface ItsNatServletContext

All Superinterfaces:
ItsNatUserData

public interface ItsNatServletContext
extends ItsNatUserData

Is the ItsNat wrapper object of the standard javax.servlet.ServletContext.

There is only one instance of this interface per web application.

Author:
Jose Maria Arranz Santamaria
See Also:
ItsNatServlet.getItsNatServletContext(), ItsNatServletConfig.getItsNatServletContext(), ItsNatSession.getItsNatServletContext()

Method Summary
 ItsNatVariableResolver createItsNatVariableResolver()
          Creates a variable resolver bound to this context.
 void enumerateSessions(ItsNatSessionCallback callback)
          Enumerates all ItsNat sessions associated to this context.
 ItsNat getItsNat()
          Returns the ItsNat "root" object used to create this object.
 int getMaxOpenDocumentsBySession()
          Returns the max number of open documents in a user web session (documents saving state on the server).
 javax.servlet.ServletContext getServletContext()
          Returns the standard servlet context wrapped.
 boolean isSessionExplicitSerialize()
          Defines whether ItsNat explicitly serializes user sessions and saves serialized data to the native sessions as attributes when any web request ends and deserializing in the beginning of any web request.
 boolean isSessionReplicationCapable()
          Controls whether the ItsNat application is ready for automatic session replication of the servlet container.
 boolean isSessionSerializeCompressed()
          Defines whether the serialized data of the ItsNat session is compressed when the session is serialized.
 void setMaxOpenDocumentsBySession(int value)
          Sets the max number of open documents in a user web session (documents saving state on the server).
 void setSessionExplicitSerialize(boolean value)
          Configures ItsNat to explicitly serialize user sessions and save serialized data to the native sessions as attributes when any web request ends and deserializing in the beginning of any web request.
 void setSessionReplicationCapable(boolean value)
          Sets whether the ItsNat application is ready for automatic session replication by the servlet container.
 void setSessionSerializeCompressed(boolean value)
          Sets whether the serialized data of the ItsNat session is compressed when the session is serialized.
 
Methods inherited from interface org.itsnat.core.ItsNatUserData
containsUserValueName, getUserValue, getUserValueNames, removeUserValue, setUserValue
 

Method Detail

getServletContext

javax.servlet.ServletContext getServletContext()
Returns the standard servlet context wrapped.

Returns:
the servlet context.

getItsNat

ItsNat getItsNat()
Returns the ItsNat "root" object used to create this object.

Returns:
the parent ItsNat object.

getMaxOpenDocumentsBySession

int getMaxOpenDocumentsBySession()
Returns the max number of open documents in a user web session (documents saving state on the server).

When this number is surpassed, older documents (documents not accesed for a long time ago) are invalidated/removed from the server.

A negative number means no limit.

Documents open through iframe, object or embed elements are included in this number, so the max number of open documents must be greater than the number of child documents of any page +1 (the container page). A number slightly greater is preferred (sometimes MSIE needs two requests to load the content of an iframe/object/page, that is, the page is loaded twice).

This feature is very useful to limit the server memory used by web bots (crawlers) unsupported browsers and browsers with JavaScript disabled traversing pages/documents with state (events enabled).

This feature only affects to documents not to fragments.

Returns:
the max number of open documents. Defaults to 10.
See Also:
setMaxOpenDocumentsBySession(int)

setMaxOpenDocumentsBySession

void setMaxOpenDocumentsBySession(int value)
Sets the max number of open documents in a user web session (documents saving state on the server).

Parameters:
value - the new max number of open documents.
See Also:
getMaxOpenDocumentsBySession()

isSessionReplicationCapable

boolean isSessionReplicationCapable()
Controls whether the ItsNat application is ready for automatic session replication of the servlet container.

When this method returns true, the ItsNat session (ItsNatHttpSession) is registered as an attribute in the native session calling HttpSession.setAttribute(String,Object) and the ItsNat session is ever obtained calling HttpSession.getAttribute(String). The method HttpSession.setAttribute(String,Object) is ever called when any event processing finishes.

In an automatic session replication environment like Google App Engine (GAE), GAE automatically serializes the ItsNat session per web request, in theory GAE automatically manages concurrency between nodes and only processes one web request each time in every session.

If session replication is set to true, the ItsNat session id as returned by ItsNatSession.getId() is the SHA-1 value of the native session id returned by HttpSession.getId(), this ensures the ItsNat session id is the same between nodes. This non-reversible ItsNat session id (SHA-1 is a one-way algorithm) is interesting because in remote/view control ItsNat session ids can be public, only ItsNat session ids are recognized because publishing the native id is not a good idea because it grants full control to other users of the monitored session outside ItsNat control.

If the servlet environment is one only node (one servlet container instance) or is not doing session replication, and session replication capable is set to true, there is no appreciable difference in performance and behaviour.

Anyway if this method returns true the servlet container can serialize the session content, this implies any user defined class bound to the session usually through ItsNat documents, must implement java.io.Serializable.

If the servlet environment actually does session replication, like GAE, some ItsNat features may not work.

If session replication capable feature is set to false the method HttpSession.setAttribute(String,Object) is not used to store the session, hence no java.io.Serializable requirement applies to user code. Use this mode when running your web application in a single node or multiple nodes configured to use sticky sessions.

Returns:
true if session replication capability is enabled. Default is false.
See Also:
setSessionReplicationCapable(boolean)

setSessionReplicationCapable

void setSessionReplicationCapable(boolean value)
Sets whether the ItsNat application is ready for automatic session replication by the servlet container.

Parameters:
value - the new mode.
See Also:
isSessionReplicationCapable()

isSessionSerializeCompressed

boolean isSessionSerializeCompressed()
Defines whether the serialized data of the ItsNat session is compressed when the session is serialized.

This feature is useful to reduce the amount of transported data between nodes in a cloud environment with session replication.

This configuration option set to true only has sense if session replication is enabled and when the servlet container serializes sessions.

Returns:
true if session compression is enabled. Default is false.
See Also:
setSessionSerializeCompressed(boolean), isSessionReplicationCapable()

setSessionSerializeCompressed

void setSessionSerializeCompressed(boolean value)
Sets whether the serialized data of the ItsNat session is compressed when the session is serialized.

Parameters:
value - the new mode.
See Also:
isSessionSerializeCompressed()

isSessionExplicitSerialize

boolean isSessionExplicitSerialize()
Defines whether ItsNat explicitly serializes user sessions and saves serialized data to the native sessions as attributes when any web request ends and deserializing in the beginning of any web request.

This feature is useful to simulate how cloud environments with session replication works and to avoid serialization time limits imposed by the cloud (for instance Google App Engine).

This configuration option set to true only does something if session replication is enabled.

Returns:
true if explicit session serialization is enabled. Default is false.
See Also:
setSessionExplicitSerialize(boolean), isSessionReplicationCapable()

setSessionExplicitSerialize

void setSessionExplicitSerialize(boolean value)
Configures ItsNat to explicitly serialize user sessions and save serialized data to the native sessions as attributes when any web request ends and deserializing in the beginning of any web request.

Parameters:
value - the new mode.
See Also:
isSessionExplicitSerialize()

enumerateSessions

void enumerateSessions(ItsNatSessionCallback callback)
Enumerates all ItsNat sessions associated to this context.

The specified callback is called per each session.

Parameters:
callback - the callback object to call per each session.

createItsNatVariableResolver

ItsNatVariableResolver createItsNatVariableResolver()
Creates a variable resolver bound to this context.

Returns:
a variable resolver bound to this context.


Copyright © 2007 Innowhere Software Services S.L. All Rights Reserved.