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
           
protected static java.util.logging.Logger log
           
 
Constructor Summary
SessionImpl(SessionManager manager, java.lang.String id, long creationTime)
          Create a new session object.
 
Method Summary
 boolean canLog()
           
protected  java.util.Map<java.lang.String,java.lang.Object> createValueMap()
          Create the map used to objectStore values.
 void finish()
          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.
 ServletAuthenticator getAuthenticator()
          Returns the authenticator
 long getCreationTime()
          Returns the time the session was created.
 java.lang.String getId()
          Returns the session identifier.
 long getLastAccessedTime()
          Returns the last objectAccess time.
 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.  
 java.security.Principal getUser()
          Returns the user
 java.lang.Object getValue(java.lang.String name)
          Deprecated.  
 java.lang.String[] getValueNames()
          Deprecated.  
 boolean inUse()
          Returns true if the session is in use.
 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 isNew()
          Returns true if the session is new.
 boolean isValid()
          Returns true if the session is valid.
 boolean load()
          Loads the session.
 void load(Hessian2Input in)
          Loads the object from the input stream.
 void load(java.io.ObjectInput in)
          Loads the object from the input stream.
 void log(java.lang.String value)
           
 void logout()
          Logs out the user
 void logout(SessionImpl timeoutSession)
          Logs out the user
 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 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 setUser(java.security.Principal user)
          Sets the user
 void store(Hessian2Output out)
          Saves the object to the input stream.
 void store(java.io.ObjectOutput out)
          Saves the object to the input stream.
 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

log

protected static final java.util.logging.Logger log

_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

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.


getAuthenticator

public ServletAuthenticator getAuthenticator()
Returns the authenticator


getUser

public java.security.Principal getUser()
Returns the user


setUser

public void setUser(java.security.Principal user)
Sets the user


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

createValueMap

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


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

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.


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

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

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)


logout

public void logout()
Logs out the user


logout

public void logout(SessionImpl timeoutSession)
Logs out the user

Parameters:
session - the session in case of timeout and single-signon

inUse

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


load

public boolean load()
Loads the session.


passivate

public void passivate()
Passivates the session.


unbind

public void unbind()
Cleans up the session.


finish

public void finish()
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.


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.


isEmpty

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


load

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

Throws:
java.io.IOException

store

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

Throws:
java.io.IOException

load

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

Throws:
java.io.IOException

store

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

Throws:
java.io.IOException

canLog

public boolean canLog()

log

public void log(java.lang.String value)

toString

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