org.sakaiproject.component.kernel.session
Class SessionComponent.MySession

java.lang.Object
  extended byorg.sakaiproject.component.kernel.session.SessionComponent.MySession
All Implemented Interfaces:
HttpSession, Session
Enclosing class:
SessionComponent

public class SessionComponent.MySession
extends Object
implements Session, HttpSession

Entity: Session Also is an HttpSession


Field Summary
protected  long m_accessed
          Time last accessed (via getSession()).
protected  Map m_attributes
          Hold attributes in a Map.
protected  Map m_contextSessions
          Hold context toolSessions in a Map, by context (webapp) id.
protected  long m_created
          The creation time of the session.
protected  String m_id
          The session id.
protected  int m_inactiveInterval
          Seconds of inactive time before being automatically invalidated - 0 turns off this feature.
protected  Map m_toolSessions
          Hold toolSessions in a Map, by placement id.
protected  String m_userEid
          The user enterprise id for this session.
protected  String m_userId
          The user id for this session.
protected  boolean m_valid
          True while the session is valid.
 
Constructor Summary
SessionComponent.MySession()
           
SessionComponent.MySession(String id)
           
 
Method Summary
protected  void bind(String name, Object value)
          Bind the value if it's a SessionBindingListener.
 boolean equals(Object obj)
          
 Object getAttribute(String name)
          Returns the object bound with the specified name in this session, or null if no object is bound under the name.
 Enumeration getAttributeNames()
          Returns an Enumeration of String objects containing the names of all the objects bound to this session.
 ContextSession getContextSession(String contextId)
          Find or create a context session for this context id
 long getCreationTime()
          Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.
 String getId()
          Returns a string containing the unique identifier assigned to this session.
 long getLastAccessedTime()
          Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT.
 int getMaxInactiveInterval()
          Returns the maximum time interval, in seconds, that Sakai will keep this session open between client accesses.
 ServletContext getServletContext()
          
 HttpSessionContext getSessionContext()
          
 ToolSession getToolSession(String placementId)
          Find or create a tool session for this tool placement id
 String getUserEid()
          Return the enterprise id of the user associated with this session.
 String getUserId()
          Return the authenticated user id associated with this session.
 Object getValue(String arg0)
          
 String[] getValueNames()
          
 int hashCode()
          
 void invalidate()
          Invalidates this session then unbinds any objects bound to it.
protected  boolean isInactive()
          Check if the session has become inactive
 boolean isNew()
          
 void putValue(String arg0, Object arg1)
          
 void removeAttribute(String name)
          Removes the object bound with the specified name from this session.
 void removeValue(String arg0)
          
 void setActive()
          Mark the session as still active, delaying timeout by another period.
 void setAttribute(String name, Object value)
          Binds an object to this session, using the name specified.
 void setMaxInactiveInterval(int interval)
          Specifies the time, in seconds, between client requests before the Sakai will invalidate this session.
 void setUserEid(String eid)
          Set the enterprise id of the user associated with this session.
 void setUserId(String uid)
          Set the user id associated with this session.
protected  void unBind(String name, Object value)
          Unbind the value if it's a SessionBindingListener.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_attributes

protected Map m_attributes
Hold attributes in a Map. TODO: ConcurrentHashMap may be better for multiple writers


m_toolSessions

protected Map m_toolSessions
Hold toolSessions in a Map, by placement id. TODO: ConcurrentHashMap may be better for multiple writers


m_contextSessions

protected Map m_contextSessions
Hold context toolSessions in a Map, by context (webapp) id. TODO: ConcurrentHashMap may be better for multiple writers


m_created

protected long m_created
The creation time of the session.


m_id

protected String m_id
The session id.


m_accessed

protected long m_accessed
Time last accessed (via getSession()).


m_inactiveInterval

protected int m_inactiveInterval
Seconds of inactive time before being automatically invalidated - 0 turns off this feature.


m_userId

protected String m_userId
The user id for this session.


m_userEid

protected String m_userEid
The user enterprise id for this session.


m_valid

protected boolean m_valid
True while the session is valid.

Constructor Detail

SessionComponent.MySession

public SessionComponent.MySession()

SessionComponent.MySession

public SessionComponent.MySession(String id)
Method Detail

getAttribute

public Object getAttribute(String name)
Description copied from interface: Session
Returns the object bound with the specified name in this session, or null if no object is bound under the name.

Specified by:
getAttribute in interface Session
Parameters:
name - a string specifying the name of the object
Returns:
the object with the specified name

getAttributeNames

public Enumeration getAttributeNames()
Description copied from interface: Session
Returns an Enumeration of String objects containing the names of all the objects bound to this session.

Specified by:
getAttributeNames in interface Session
Returns:
an Enumeration of String objects specifying the names of all the objects bound to this session

getCreationTime

public long getCreationTime()
Description copied from interface: Session
Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.

Specified by:
getCreationTime in interface Session
Returns:
a long specifying when this session was created, expressed in milliseconds since 1/1/1970 GMT

getId

public String getId()
Description copied from interface: Session
Returns a string containing the unique identifier assigned to this session.

Specified by:
getId in interface Session
Returns:
a string specifying the identifier assigned to this session

getLastAccessedTime

public long getLastAccessedTime()
Description copied from interface: Session
Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT.

Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.

Specified by:
getLastAccessedTime in interface Session
Returns:
a long representing the last time the client sent a request associated with this session, expressed in milliseconds since 1/1/1970 GMT

getMaxInactiveInterval

public int getMaxInactiveInterval()
Description copied from interface: Session
Returns the maximum time interval, in seconds, that Sakai will keep this session open between client accesses. After this interval, Sakai will invalidate the session. The maximum time interval can be set with the setMaxInactiveInterval method. A negative time indicates the session should never timeout.

Specified by:
getMaxInactiveInterval in interface Session
Returns:
an integer specifying the number of seconds this session remains open between client requests
See Also:
Session.setMaxInactiveInterval(int)

getUserEid

public String getUserEid()
Description copied from interface: Session
Return the enterprise id of the user associated with this session.

Specified by:
getUserEid in interface Session
Returns:
The enterprise id of the user associated with this session.

getUserId

public String getUserId()
Description copied from interface: Session
Return the authenticated user id associated with this session.

Specified by:
getUserId in interface Session
Returns:
The authenticated user id associated with this session.

invalidate

public void invalidate()
Description copied from interface: Session
Invalidates this session then unbinds any objects bound to it.

Specified by:
invalidate in interface Session

setActive

public void setActive()
Description copied from interface: Session
Mark the session as still active, delaying timeout by another period.

Specified by:
setActive in interface Session

removeAttribute

public void removeAttribute(String name)
Description copied from interface: Session
Removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing.

After this method executes, and if the object implements SessionBindingListener, Sakai calls SessionBindingListener.valueUnbound.

Specified by:
removeAttribute in interface Session
Parameters:
name - the name of the object to remove from this session

setAttribute

public void setAttribute(String name,
                         Object value)
Description copied from interface: Session
Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.

After this method executes, and if the new object implements SessionBindingListener, Sakai calls SessionBindingListener.valueBound.

If an object was already bound to this session of this name that implements SessionBindingListener, its SessionBindingListener.valueUnbound method is called.

If the value passed in is null, this has the same effect as calling removeAttribute().

Specified by:
setAttribute in interface Session
Parameters:
name - the name to which the object is bound; cannot be null
value - the object to be bound

setMaxInactiveInterval

public void setMaxInactiveInterval(int interval)
Description copied from interface: Session
Specifies the time, in seconds, between client requests before the Sakai will invalidate this session. A negative time indicates the session should never timeout.

Specified by:
setMaxInactiveInterval in interface Session
Parameters:
interval - An integer specifying the number of seconds

setUserEid

public void setUserEid(String eid)
Description copied from interface: Session
Set the enterprise id of the user associated with this session.

Specified by:
setUserEid in interface Session
Returns:
The enterprise id of the user associated with this session.

setUserId

public void setUserId(String uid)
Description copied from interface: Session
Set the user id associated with this session.

Specified by:
setUserId in interface Session
Parameters:
uid - The user id associated with this session.

getToolSession

public ToolSession getToolSession(String placementId)
Description copied from interface: Session
Find or create a tool session for this tool placement id

Specified by:
getToolSession in interface Session
Parameters:
placementId - The id used to identify the session.
Returns:
The ToolSession to use for this tool placement id.

getContextSession

public ContextSession getContextSession(String contextId)
Description copied from interface: Session
Find or create a context session for this context id

Specified by:
getContextSession in interface Session
Parameters:
contextId - The id used to identify the session.
Returns:
The ContextSession to use for this context id.

isInactive

protected boolean isInactive()
Check if the session has become inactive

Returns:
true if the session is capable of becoming inactive and has done so, false if not.

equals

public boolean equals(Object obj)


hashCode

public int hashCode()


getServletContext

public ServletContext getServletContext()

Specified by:
getServletContext in interface HttpSession

getSessionContext

public HttpSessionContext getSessionContext()

Specified by:
getSessionContext in interface HttpSession

getValue

public Object getValue(String arg0)

Specified by:
getValue in interface HttpSession

getValueNames

public String[] getValueNames()

Specified by:
getValueNames in interface HttpSession

putValue

public void putValue(String arg0,
                     Object arg1)

Specified by:
putValue in interface HttpSession

removeValue

public void removeValue(String arg0)

Specified by:
removeValue in interface HttpSession

isNew

public boolean isNew()

Specified by:
isNew in interface HttpSession

unBind

protected void unBind(String name,
                      Object value)
Unbind the value if it's a SessionBindingListener. Also does the HTTP unbinding if it's a HttpSessionBindingListener.

Parameters:
name - The attribute name bound.
value - The bond value.

bind

protected void bind(String name,
                    Object value)
Bind the value if it's a SessionBindingListener. Also does the HTTP binding if it's a HttpSessionBindingListener.

Parameters:
name - The attribute name bound.
value - The bond value.