com.caucho.server.session
Class SessionImpl

java.lang.Object
  extended by com.caucho.server.session.SessionImpl
All Implemented Interfaces:
CacheListener, HttpSession

public class SessionImpl
extends java.lang.Object
implements HttpSession, CacheListener

Implements a HTTP session.


Field Summary
protected  SessionManager _manager
           
protected  java.util.Map<java.lang.String,java.lang.Object> _values
           
 
Constructor Summary
SessionImpl(SessionManager manager, java.lang.String id, long creationTime)
          Create a new session object.
 
Method Summary
protected  java.util.Map<java.lang.String,java.lang.Object> createValueMap()
          Create the map used to objectStore values.
 void finishRequest()
          Cleaning up session stuff at the end of a request.
 java.lang.Object getAttribute(java.lang.String name)
          Returns the named attribute from the session.
 java.util.Enumeration getAttributeNames()
          Return an enumeration of all the sessions' attribute names.
 long getCreationTime()
          Returns the time the session was created.
 java.lang.String getId()
          Returns the session identifier.
 long getLastAccessedTime()
          Returns the last objectAccess time.
 int getLastSaveLength()
           
 SessionManager getManager()
          Returns the session manager.
 int getMaxInactiveInterval()
          Returns the time the session is allowed to be alive.
 ServletContext getServletContext()
          Returns the servlet context.
 HttpSessionContext getSessionContext()
          Deprecated.  
protected  int getUseCount()
           
 java.lang.Object getValue(java.lang.String name)
          Deprecated.  
 java.lang.String[] getValueNames()
          Deprecated.  
 void invalidate()
          Invalidates the session, called by user code.
 void invalidateLogout()
          Invalidates a session based on a logout.
 void invalidateRemote()
          Invalidates the session, called by user code.
 boolean isEmpty()
          Returns true if the session is empty.
 boolean isInUse()
          Returns true if the session is in use.
 boolean isNew()
          Returns true if the session is new.
 boolean isTimeout()
           
 boolean isValid()
          Returns true if the session is valid.
 boolean load(boolean isNew)
          Loads the session.
 void load(SessionDeserializer in)
          Loads the object from the input stream.
 void passivate()
          Passivates the session.
 void putValue(java.lang.String name, java.lang.Object value)
          Deprecated.  
 void removeAttribute(java.lang.String name)
          Remove a session attribute.
 void removeEvent()
          Callback when the session is removed from the session cache, generally because the session cache is full.
 void removeValue(java.lang.String name)
          Deprecated.  
 void save()
          Saves changes to the session.
 void saveAfterRequest()
          Flush changes after a request completes.
 void saveBeforeFlush()
          Save changes before any flush.
 void saveBeforeHeaders()
          Flush changes before the headers.
 void setAccessTime(long accessTime)
           
 void setAttribute(java.lang.String name, java.lang.Object value)
          Sets a session attribute.
 void setMaxInactiveInterval(int value)
          Sets the maximum time a session is allowed to be alive.
 void store(SessionSerializer out)
          Saves the object to the input stream.
 void timeout()
          Called by the session manager for a session timeout
 java.lang.String toString()
           
 void unbind()
          Cleans up the session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_manager

protected SessionManager _manager

_values

protected java.util.Map<java.lang.String,java.lang.Object> _values
Constructor Detail

SessionImpl

public SessionImpl(SessionManager manager,
                   java.lang.String id,
                   long creationTime)
Create a new session object.

Parameters:
manager - the owning session manager.
id - the session identifier.
creationTime - the time in milliseconds when the session was created.
Method Detail

createValueMap

protected java.util.Map<java.lang.String,java.lang.Object> createValueMap()
Create the map used to objectStore values.


getCreationTime

public long getCreationTime()
Returns the time the session was created.

Specified by:
getCreationTime in interface HttpSession

getId

public java.lang.String getId()
Returns the session identifier.

Specified by:
getId in interface HttpSession

getLastAccessedTime

public long getLastAccessedTime()
Returns the last objectAccess time.

Specified by:
getLastAccessedTime in interface HttpSession

getMaxInactiveInterval

public int getMaxInactiveInterval()
Returns the time the session is allowed to be alive.

Specified by:
getMaxInactiveInterval in interface HttpSession
Returns:
time allowed to live in seconds

setMaxInactiveInterval

public void setMaxInactiveInterval(int value)
Sets the maximum time a session is allowed to be alive.

Specified by:
setMaxInactiveInterval in interface HttpSession
Parameters:
value - time allowed to live in seconds

getSessionContext

public HttpSessionContext getSessionContext()
Deprecated. 

Returns the session context.

Specified by:
getSessionContext in interface HttpSession

getServletContext

public ServletContext getServletContext()
Returns the servlet context.

Specified by:
getServletContext in interface HttpSession

getManager

public SessionManager getManager()
Returns the session manager.


isNew

public boolean isNew()
Returns true if the session is new.

Specified by:
isNew in interface HttpSession

isValid

public boolean isValid()
Returns true if the session is valid.


isTimeout

public boolean isTimeout()

isEmpty

public boolean isEmpty()
Returns true if the session is empty.


isInUse

public boolean isInUse()
Returns true if the session is in use.


getUseCount

protected int getUseCount()

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the named attribute from the session.

Specified by:
getAttribute in interface HttpSession
Parameters:
name - of the attribute.
Returns:
stored value

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Sets a session attribute. If the value is a listener, notify it of the objectModified. If the value has changed mark the session as changed for persistent sessions.

Specified by:
setAttribute in interface HttpSession
Parameters:
name - the name of the attribute
value - the value of the attribute

removeAttribute

public void removeAttribute(java.lang.String name)
Remove a session attribute. If the value is a listener, notify it of the objectModified.

Specified by:
removeAttribute in interface HttpSession
Parameters:
name - the name of the attribute to objectRemove

getAttributeNames

public java.util.Enumeration getAttributeNames()
Return an enumeration of all the sessions' attribute names.

Specified by:
getAttributeNames in interface HttpSession
Returns:
enumeration of the attribute names.

getValue

public java.lang.Object getValue(java.lang.String name)
Deprecated. 

Specified by:
getValue in interface HttpSession

putValue

public void putValue(java.lang.String name,
                     java.lang.Object value)
Deprecated. 

Specified by:
putValue in interface HttpSession

removeValue

public void removeValue(java.lang.String name)
Deprecated. 

Specified by:
removeValue in interface HttpSession

getValueNames

public java.lang.String[] getValueNames()
Deprecated. 

Specified by:
getValueNames in interface HttpSession

setAccessTime

public void setAccessTime(long accessTime)

getLastSaveLength

public int getLastSaveLength()

finishRequest

public void finishRequest()
Cleaning up session stuff at the end of a request.

If the session data has changed and we have persistent sessions, save the session. However, if save-on-shutdown is true, only save on a server shutdown.


load

public boolean load(boolean isNew)
Loads the session.

Returns:
true if the session was found in the persistent store

load

public void load(SessionDeserializer in)
          throws java.io.IOException
Loads the object from the input stream.

Throws:
java.io.IOException

saveBeforeFlush

public final void saveBeforeFlush()
Save changes before any flush.


saveBeforeHeaders

public final void saveBeforeHeaders()
Flush changes before the headers.


saveAfterRequest

public final void saveAfterRequest()
Flush changes after a request completes.


save

public final void save()
Saves changes to the session.


passivate

public void passivate()
Passivates the session.


store

public void store(SessionSerializer out)
           throws java.io.IOException
Saves the object to the input stream.

Throws:
java.io.IOException

invalidate

public void invalidate()
Invalidates the session, called by user code. This should never be called by Resin code (for logging purposes)

Specified by:
invalidate in interface HttpSession

timeout

public void timeout()
Called by the session manager for a session timeout


removeEvent

public void removeEvent()
Callback when the session is removed from the session cache, generally because the session cache is full.

Specified by:
removeEvent in interface CacheListener

invalidateLogout

public void invalidateLogout()
Invalidates a session based on a logout.


invalidateRemote

public void invalidateRemote()
Invalidates the session, called by user code. This should never be called by Resin code (for logging purposes)


unbind

public void unbind()
Cleans up the session.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object