org.directwebremoting.impl
Class DefaultScriptSessionManager

java.lang.Object
  extended by org.directwebremoting.impl.DefaultScriptSessionManager
All Implemented Interfaces:
InitializingBean, ScriptSessionManager, UninitializingBean

public class DefaultScriptSessionManager
extends java.lang.Object
implements ScriptSessionManager, InitializingBean, UninitializingBean

A default implementation of ScriptSessionManager.

There are synchronization constraints on this class that could be broken by subclasses. Specifically anyone accessing either sessionMap or pageSessionMap must be holding the sessionLock.

In addition you should note that DefaultScriptSession and DefaultScriptSessionManager make calls to each other and you should take care not to break any constraints in inheriting from these classes.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Field Summary
static java.lang.String ATTRIBUTE_HTTPSESSIONID
          Use of this attribute is currently discouraged, we may make this public in a later release.
static java.lang.String ATTRIBUTE_PAGE
          Use of this attribute is currently discouraged, we may make this public in a later release.
 
Fields inherited from interface org.directwebremoting.extend.ScriptSessionManager
DEFAULT_TIMEOUT_MILLIS
 
Constructor Summary
DefaultScriptSessionManager()
           
 
Method Summary
 void addScriptSessionListener(ScriptSessionListener li)
          Maintain the list of ScriptSessionListeners
 void afterContainerSetup(Container container)
          This method allows the bean instance to perform initialization only possible when all bean properties have been set
 void contextDestroyed()
          Called when a ServletContext is being destroyed.
 java.util.Collection<ScriptSession> getAllScriptSessions()
          Get a list of all the currently known ScriptSessions by id.
 java.lang.String getInitCode()
          Some implementations of ScriptSessionManager need to add custom code into engine.js to register ScriptSessions with the server.
 RealScriptSession getScriptSession(java.lang.String sentScriptId, java.lang.String page, java.lang.String httpSessionId)
          For a given script session id, return the related ScriptSession object or null if the id is not known.
 java.util.Collection<RealScriptSession> getScriptSessionsByHttpSessionId(java.lang.String httpSessionId)
          Lookup all the windows associated with a given browser
 long getScriptSessionTimeout()
          Accessor for the time (in milliseconds) when unused ScriptSessions will expire
 void removeScriptSessionListener(ScriptSessionListener li)
          Maintain the list of ScriptSessionListeners
 void servletDestroyed()
          Called when GenericServlet.destroy() is called.
 void setPageNormalizer(PageNormalizer pageNormalizer)
          How we turn pages into the canonical form.
 void setScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor executor)
          How often do we check for script sessions that need timing out
 void setScriptSessionCheckTime(long scriptSessionCheckTime)
          How often do we check for script sessions that need timing out
 void setScriptSessionTimeout(long scriptSessionTimeout)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_HTTPSESSIONID

public static final java.lang.String ATTRIBUTE_HTTPSESSIONID
Use of this attribute is currently discouraged, we may make this public in a later release. Until then, it may change or be removed without warning.

See Also:
Constant Field Values

ATTRIBUTE_PAGE

public static final java.lang.String ATTRIBUTE_PAGE
Use of this attribute is currently discouraged, we may make this public in a later release. Until then, it may change or be removed without warning.

See Also:
Constant Field Values
Constructor Detail

DefaultScriptSessionManager

public DefaultScriptSessionManager()
Method Detail

afterContainerSetup

public void afterContainerSetup(Container container)
Description copied from interface: InitializingBean

This method allows the bean instance to perform initialization only possible when all bean properties have been set

Specified by:
afterContainerSetup in interface InitializingBean
Parameters:
container - The container that is doing the initialization

contextDestroyed

public void contextDestroyed()
Description copied from interface: UninitializingBean
Called when a ServletContext is being destroyed. DWR finds out about this destruction if (and only if) in web.xml there is a DwrListener registered. This happens before the GenericServlet.destroy() is called.

If DwrListener is not registered, this will not happen

This method should only be used when we need to take action to enable the servlet to stop cleanly. Typically this will be restricted to stopping reverse ajax threads.

Specified by:
contextDestroyed in interface UninitializingBean

servletDestroyed

public void servletDestroyed()
Description copied from interface: UninitializingBean
Called when GenericServlet.destroy() is called. This event is the preferred time to close resources that don't require all connections to be closed. The servletDestroy method is far more likely to be called.

Specified by:
servletDestroyed in interface UninitializingBean

getScriptSession

public RealScriptSession getScriptSession(java.lang.String sentScriptId,
                                          java.lang.String page,
                                          java.lang.String httpSessionId)
Description copied from interface: ScriptSessionManager
For a given script session id, return the related ScriptSession object or null if the id is not known.

Specified by:
getScriptSession in interface ScriptSessionManager
Parameters:
sentScriptId - The id to get a ScriptSession object for
page - The URL including 'http://', up to (but not including) '?' or '#' (or null if not known)
httpSessionId - The session ID (or null if not known)
Returns:
A ScriptSession to match the ID, or null if a match is not found.

getScriptSessionsByHttpSessionId

public java.util.Collection<RealScriptSession> getScriptSessionsByHttpSessionId(java.lang.String httpSessionId)
Description copied from interface: ScriptSessionManager
Lookup all the windows associated with a given browser

Specified by:
getScriptSessionsByHttpSessionId in interface ScriptSessionManager
Parameters:
httpSessionId - The browser id to lookup
Returns:
A list of script sessions for each open window

getAllScriptSessions

public java.util.Collection<ScriptSession> getAllScriptSessions()
Description copied from interface: ScriptSessionManager
Get a list of all the currently known ScriptSessions by id. Note that the list of known sessions is continually changing so it is possible that the list will be out of date by the time it is used. For this reason you should check that getScriptSession(String id) returns something non null.

Specified by:
getAllScriptSessions in interface ScriptSessionManager
Returns:
An iterator over the currently known sessions, by id

addScriptSessionListener

public void addScriptSessionListener(ScriptSessionListener li)
Description copied from interface: ScriptSessionManager
Maintain the list of ScriptSessionListeners

Specified by:
addScriptSessionListener in interface ScriptSessionManager
Parameters:
li - the ScriptSessionListener to add

removeScriptSessionListener

public void removeScriptSessionListener(ScriptSessionListener li)
Description copied from interface: ScriptSessionManager
Maintain the list of ScriptSessionListeners

Specified by:
removeScriptSessionListener in interface ScriptSessionManager
Parameters:
li - the ScriptSessionListener to remove

getInitCode

public java.lang.String getInitCode()
Description copied from interface: ScriptSessionManager
Some implementations of ScriptSessionManager need to add custom code into engine.js to register ScriptSessions with the server.

Specified by:
getInitCode in interface ScriptSessionManager

getScriptSessionTimeout

public long getScriptSessionTimeout()
Description copied from interface: ScriptSessionManager
Accessor for the time (in milliseconds) when unused ScriptSessions will expire

Specified by:
getScriptSessionTimeout in interface ScriptSessionManager
Returns:
the scriptSessionTimeout

setScriptSessionTimeout

public void setScriptSessionTimeout(long scriptSessionTimeout)

setPageNormalizer

public void setPageNormalizer(PageNormalizer pageNormalizer)
How we turn pages into the canonical form.

Parameters:
pageNormalizer - The new PageNormalizer

setScriptSessionCheckTime

public void setScriptSessionCheckTime(long scriptSessionCheckTime)
How often do we check for script sessions that need timing out


setScheduledThreadPoolExecutor

public void setScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor executor)
How often do we check for script sessions that need timing out


Copyright 2008