org.w3c.jigsaw.servlet
Class JigsawHttpSession

java.lang.Object
  extended by org.w3c.jigsaw.servlet.JigsawHttpSession
All Implemented Interfaces:
javax.servlet.http.HttpSession

public class JigsawHttpSession
extends java.lang.Object
implements javax.servlet.http.HttpSession


Constructor Summary
JigsawHttpSession(JigsawHttpSessionContext context, JigsawServletContext servletContext, javax.servlet.http.Cookie cookie)
           
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Returns the object bound with the specified name in this session, or null if no object is bound under the name.
 java.util.Enumeration getAttributeNames()
          Returns an Enumeration of String objects containing the names of all the objects bound to this session.
protected  javax.servlet.http.Cookie getCookie()
           
 long getCreationTime()
          Returns the time at which this session representation was created, in milliseconds since midnight, January 1, 1970 UTC.
 java.lang.String getId()
          Returns the identifier assigned to this session.
 long getLastAccessedTime()
          Returns the last time the client sent a request carrying the identifier assigned to the session.
 int getMaxInactiveInterval()
           
 javax.servlet.ServletContext getServletContext()
           
 javax.servlet.http.HttpSessionContext getSessionContext()
          Deprecated. since jsdk2.1
 java.lang.Object getValue(java.lang.String name)
          Returns the object bound to the given name in the session's application layer data.
 java.lang.String[] getValueNames()
          Deprecated. since jsdk2.2
 void invalidate()
          Causes this representation of the session to be invalidated and removed from its context.
 boolean isNew()
          A session is considered to be "new" if it has been created by the server, but the client has not yet acknowledged joining the session.
protected  boolean isValid()
           
 void putValue(java.lang.String name, java.lang.Object value)
          Binds the specified object into the session's application layer data with the given name.
 void removeAttribute(java.lang.String name)
          Removes the object bound with the specified name from this session.
 void removeValue(java.lang.String name)
          Removes the object bound to the given name in the session's application layer data.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Binds an object to this session, using the name specified.
protected  void setLastAccessedTime()
           
 void setMaxInactiveInterval(int interval)
           
protected  void setNoMoreNew()
           
protected  void valueBound(javax.servlet.http.HttpSessionBindingListener value, java.lang.String name)
           
protected  void valueUnbound(javax.servlet.http.HttpSessionBindingListener value, java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JigsawHttpSession

public JigsawHttpSession(JigsawHttpSessionContext context,
                         JigsawServletContext servletContext,
                         javax.servlet.http.Cookie cookie)
Method Detail

getId

public java.lang.String getId()
Returns the identifier assigned to this session. An HttpSession's identifier is a unique string that is created and maintained by HttpSessionContext.

Specified by:
getId in interface javax.servlet.http.HttpSession
Returns:
the identifier assigned to this session
Throws:
java.lang.IllegalStateException - if an attempt is made to access session data after the session has been invalidated

getSessionContext

public javax.servlet.http.HttpSessionContext getSessionContext()
Deprecated. since jsdk2.1

Returns the context in which this session is bound.

Specified by:
getSessionContext in interface javax.servlet.http.HttpSession
Returns:
the context in which this session is bound.
Throws:
java.lang.IllegalStateException - if an attempt is made to access session data after the session has been invalidated

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
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 javax.servlet.http.HttpSession
Parameters:
name - a string specifying the name of the object
Returns:
the object with the specified name
Throws:
java.lang.IllegalStateException - if this method is called on an invalidated session

getAttributeNames

public java.util.Enumeration getAttributeNames()
Returns an Enumeration of String objects containing the names of all the objects bound to this session.

Specified by:
getAttributeNames in interface javax.servlet.http.HttpSession
Returns:
an Enumeration of String objects specifying the names of all the objects bound to this session
Throws:
java.lang.IllegalStateException - if this method is called on an invalidated session

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
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 object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueBound.

Specified by:
setAttribute in interface javax.servlet.http.HttpSession
Parameters:
name - the name to which the object is bound; cannot be null
value - the object to be bound; cannot be null
Throws:
java.lang.IllegalStateException - if this method is called on an invalidated session

removeAttribute

public void removeAttribute(java.lang.String name)
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 HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueUnbound.

Specified by:
removeAttribute in interface javax.servlet.http.HttpSession
Parameters:
name - the name of the object to remove from this session
Throws:
java.lang.IllegalStateException - if this method is called on an invalidated session

getCreationTime

public long getCreationTime()
Returns the time at which this session representation was created, in milliseconds since midnight, January 1, 1970 UTC.

Specified by:
getCreationTime in interface javax.servlet.http.HttpSession
Returns:
the time when the session was created
Throws:
java.lang.IllegalStateException - if an attempt is made to access session data after the session has been invalidated

getLastAccessedTime

public long getLastAccessedTime()
Returns the last time the client sent a request carrying the identifier assigned to the session. Time is expressed as milliseconds since midnight, January 1, 1970 UTC. Application level operations, such as getting or setting a value associated with the session, does not affect the access time.

Specified by:
getLastAccessedTime in interface javax.servlet.http.HttpSession
Returns:
the last time the client sent a request carrying the identifier assigned to the session
Throws:
java.lang.IllegalStateException - if an attempt is made to access session data after the session has been invalidated

setLastAccessedTime

protected void setLastAccessedTime()

invalidate

public void invalidate()
Causes this representation of the session to be invalidated and removed from its context.

Specified by:
invalidate in interface javax.servlet.http.HttpSession
Throws:
java.lang.IllegalStateException - if an attempt is made to access session data after the session has been invalidated

getValue

public java.lang.Object getValue(java.lang.String name)
Returns the object bound to the given name in the session's application layer data. Returns null if there is no such binding.

Specified by:
getValue in interface javax.servlet.http.HttpSession
Parameters:
name - - the name of the binding to find
Returns:
the value bound to that name, or null if the binding does not exist.
Throws:
java.lang.IllegalStateException - if an attempt is made to access session data after the session has been invalidated

putValue

public void putValue(java.lang.String name,
                     java.lang.Object value)
Binds the specified object into the session's application layer data with the given name. Any existing binding with the same name is replaced. New (or existing) values that implement the HttpSessionBindingListener interface will call its valueBound() method.

Specified by:
putValue in interface javax.servlet.http.HttpSession
Parameters:
name - - the name to which the data object will be bound. This parameter cannot be null.
value - - the data object to be bound. This parameter cannot be null.
Throws:
java.lang.IllegalStateException - if an attempt is made to access session data after the session has been invalidated

removeValue

public void removeValue(java.lang.String name)
Removes the object bound to the given name in the session's application layer data. Does nothing if there is no object bound to the given name. The value that implements the HttpSessionBindingListener interface will call its valueUnbound() method.

Specified by:
removeValue in interface javax.servlet.http.HttpSession
Parameters:
name - - the name of the object to remove
Throws:
java.lang.IllegalStateException - if an attempt is made to access session data after the session has been invalidated

valueBound

protected void valueBound(javax.servlet.http.HttpSessionBindingListener value,
                          java.lang.String name)

valueUnbound

protected void valueUnbound(javax.servlet.http.HttpSessionBindingListener value,
                            java.lang.String name)

getValueNames

public java.lang.String[] getValueNames()
Deprecated. since jsdk2.2

Returns an array of the names of all the application layer data objects bound into the session. For example, if you want to delete all of the data objects bound into the session, use this method to obtain their names.

Specified by:
getValueNames in interface javax.servlet.http.HttpSession
Returns:
an array containing the names of all of the application layer data objects bound into the session
Throws:
java.lang.IllegalStateException - if an attempt is made to access session data after the session has been invalidated

isNew

public boolean isNew()
A session is considered to be "new" if it has been created by the server, but the client has not yet acknowledged joining the session. For example, if the server supported only cookie-based sessions and the client had completely disabled the use of cookies, then calls to HttpServletRequest.getSession() would always return "new" sessions.

Specified by:
isNew in interface javax.servlet.http.HttpSession
Returns:
true if the session has been created by the server but the client has not yet acknowledged joining the session; false otherwise
Throws:
java.lang.IllegalStateException - if an attempt is made to access session data after the session has been invalidated

setNoMoreNew

protected void setNoMoreNew()

isValid

protected boolean isValid()

getCookie

protected javax.servlet.http.Cookie getCookie()

setMaxInactiveInterval

public void setMaxInactiveInterval(int interval)
Specified by:
setMaxInactiveInterval 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()