org.japano
Class Session

java.lang.Object
  extended by org.japano.Session
All Implemented Interfaces:
java.io.Serializable, javax.servlet.http.HttpSession

public class Session
extends java.lang.Object
implements javax.servlet.http.HttpSession, java.io.Serializable

Base class for all session implementations which provides basic japano functionality. Subclass implementations must register via an init-parameter in the web.xml file. JSP compilation will use its knowledge of that sub type to optimize access. (e.g. ${pageContext.session.user} is resolved to "((SampleSession)pageContext.getSession()).getUser()" in the JSP code) The implementation uses a secure random generator from Util.createSecureRandom() to generate the session IDs.

Version:
$Id: Session.java,v 1.21 2005/11/30 21:22:23 fforw Exp $ SourceForge.net Logo
Author:
Sven Helmberger ( sven dot helmberger at gmx dot de )
See Also:
Util.createSecureRandom(), Serialized Form

Field Summary
protected static java.util.Map allSessions
          maps session ids to Session instances
protected static java.util.Map botSessions
           
static int DEFAULT_MAX_INACTIVE_INTERVAL
           
protected  JapanoConfig japanoConfig
           
protected static int SESSION_ID_LENGTH
           
static java.lang.String SESSIONS_FILE
           
 
Constructor Summary
protected Session()
          protected Session contstructor
protected Session(java.lang.String sessionId)
          Creates a new instance of Session
 
Method Summary
 void access()
           
 void addActionParameter(java.lang.String qName, ActionParameter formContent)
           
protected static Session addSession(java.lang.String id, JapanoConfig japanoConfig)
           
 void addValidationAttribute(java.lang.String paramName, java.lang.Object value)
           
 void addViewMessage(java.lang.String message)
          Adds a message to this session's view.
 void clearValidationAttributes()
           
 PingPongContext createPingPongAction(java.lang.String qName)
           
protected static Session createSession(JapanoConfig japanoConfig)
          Returns a new session with a proven unique session id.
protected  void destroy()
          Destroys the session when it's removed from the session pool.
static boolean exists(java.lang.String sessionId)
           
 ActionConfig getActionConfig()
          Returns the ActionConfig for the website this session instance belongs to.
 int getActionCount()
           
 ActionParameter getActionParameter(java.lang.String qName)
           
 java.lang.Object getAttribute(java.lang.String str)
           
 java.util.Enumeration getAttributeNames()
           
 long getCreationTime()
           
 java.lang.String getId()
           
 IDMechanism getIdMechanism()
          Returns how the session id is transported in between client requests.
 long getLastAccessedTime()
           
 java.util.Locale getLocale()
          Getter for property locale.
 int getMaxInactiveInterval()
           
 javax.servlet.ServletContext getServletContext()
           
static Session getSession(java.lang.String sessionId)
           
 javax.servlet.http.HttpSessionContext getSessionContext()
           
 java.lang.Object getValidationAttribute(java.lang.String paramName)
           
 java.lang.Object getValue(java.lang.String str)
           
 java.lang.String[] getValueNames()
           
 View getView()
          Returns the current view of this session.
 void increaseActionCount()
           
 void invalidate()
           
 boolean isBot()
          Getter for property bot.
 boolean isNew()
           
 void putValue(java.lang.String str, java.lang.Object obj)
           
 void removeAttribute(java.lang.String str)
           
 PingPongContext removePingPongContext(java.lang.String qName)
           
 void removeValue(java.lang.String str)
           
 void setAttribute(java.lang.String str, java.lang.Object obj)
           
protected  void setId(java.lang.String id)
           
 void setIdMechanism(IDMechanism idMechanism)
           
 void setLocale(java.util.Locale locale)
          Setter for property locale.
 void setMaxInactiveInterval(int param)
           
 View setView(java.lang.String URI)
          Sets this session to a new view.
 View setVolatileView(java.lang.String URI)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_INACTIVE_INTERVAL

public static final int DEFAULT_MAX_INACTIVE_INTERVAL
See Also:
Constant Field Values

SESSIONS_FILE

public static final java.lang.String SESSIONS_FILE
See Also:
Constant Field Values

allSessions

protected static java.util.Map allSessions
maps session ids to Session instances


botSessions

protected static java.util.Map botSessions

japanoConfig

protected transient JapanoConfig japanoConfig

SESSION_ID_LENGTH

protected static final int SESSION_ID_LENGTH
Constructor Detail

Session

protected Session()
protected Session contstructor


Session

protected Session(java.lang.String sessionId)
Creates a new instance of Session

Method Detail

setId

protected void setId(java.lang.String id)

getId

public java.lang.String getId()
Specified by:
getId in interface javax.servlet.http.HttpSession

getSession

public static Session getSession(java.lang.String sessionId)

exists

public static boolean exists(java.lang.String sessionId)

access

public void access()

addSession

protected static Session addSession(java.lang.String id,
                                    JapanoConfig japanoConfig)

createSession

protected static Session createSession(JapanoConfig japanoConfig)
Returns a new session with a proven unique session id. It is ensured that the created session does have a unique id. The length of the session is defined by system property "japano.sessionid.length" or 16 if the property is not set.

Parameters:
japanoConfig - JapanoConfig

getAttributeNames

public java.util.Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface javax.servlet.http.HttpSession

getAttribute

public java.lang.Object getAttribute(java.lang.String str)
Specified by:
getAttribute in interface javax.servlet.http.HttpSession

removeAttribute

public void removeAttribute(java.lang.String str)
Specified by:
removeAttribute in interface javax.servlet.http.HttpSession

setAttribute

public void setAttribute(java.lang.String str,
                         java.lang.Object obj)
Specified by:
setAttribute in interface javax.servlet.http.HttpSession

getCreationTime

public long getCreationTime()
Specified by:
getCreationTime in interface javax.servlet.http.HttpSession

getLastAccessedTime

public long getLastAccessedTime()
Specified by:
getLastAccessedTime in interface javax.servlet.http.HttpSession

getMaxInactiveInterval

public int getMaxInactiveInterval()
Specified by:
getMaxInactiveInterval in interface javax.servlet.http.HttpSession

getServletContext

public javax.servlet.ServletContext getServletContext()
Specified by:
getServletContext in interface javax.servlet.http.HttpSession

getSessionContext

public javax.servlet.http.HttpSessionContext getSessionContext()
Specified by:
getSessionContext in interface javax.servlet.http.HttpSession

getValue

public java.lang.Object getValue(java.lang.String str)
Specified by:
getValue in interface javax.servlet.http.HttpSession

getValueNames

public java.lang.String[] getValueNames()
Specified by:
getValueNames in interface javax.servlet.http.HttpSession

invalidate

public void invalidate()
Specified by:
invalidate in interface javax.servlet.http.HttpSession

isNew

public boolean isNew()
Specified by:
isNew in interface javax.servlet.http.HttpSession

putValue

public void putValue(java.lang.String str,
                     java.lang.Object obj)
Specified by:
putValue in interface javax.servlet.http.HttpSession

removeValue

public void removeValue(java.lang.String str)
Specified by:
removeValue in interface javax.servlet.http.HttpSession

setMaxInactiveInterval

public void setMaxInactiveInterval(int param)
Specified by:
setMaxInactiveInterval in interface javax.servlet.http.HttpSession

getActionCount

public int getActionCount()

increaseActionCount

public void increaseActionCount()

createPingPongAction

public PingPongContext createPingPongAction(java.lang.String qName)

removePingPongContext

public PingPongContext removePingPongContext(java.lang.String qName)

getActionConfig

public ActionConfig getActionConfig()
Returns the ActionConfig for the website this session instance belongs to.


addValidationAttribute

public void addValidationAttribute(java.lang.String paramName,
                                   java.lang.Object value)

getValidationAttribute

public java.lang.Object getValidationAttribute(java.lang.String paramName)

clearValidationAttributes

public void clearValidationAttributes()

setView

public View setView(java.lang.String URI)
Sets this session to a new view. Returns the new view for convenience.

Parameters:
URI - URI of the view
Returns:
the view (for convenience)

setVolatileView

public View setVolatileView(java.lang.String URI)

getView

public View getView()
Returns the current view of this session.


addViewMessage

public void addViewMessage(java.lang.String message)
Adds a message to this session's view.

Parameters:
message - message to add to the view

addActionParameter

public void addActionParameter(java.lang.String qName,
                               ActionParameter formContent)

getActionParameter

public ActionParameter getActionParameter(java.lang.String qName)

getIdMechanism

public IDMechanism getIdMechanism()
Returns how the session id is transported in between client requests.

Returns:
id mechanism
See Also:
IDMechanism

setIdMechanism

public void setIdMechanism(IDMechanism idMechanism)

isBot

public boolean isBot()
Getter for property bot.

Returns:
Value of property bot.

destroy

protected void destroy()
Destroys the session when it's removed from the session pool. Subclasses can overload this method to clean up all resources associated with the session.


getLocale

public java.util.Locale getLocale()
Getter for property locale.

Returns:
Value of property locale.

setLocale

public void setLocale(java.util.Locale locale)
Setter for property locale.

Parameters:
locale - New value of property locale.