Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.jserv
Class JServSession

    java.lang.Object
      |
      +--org.apache.jserv.JServSession

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

This is the object that encapsulates a session.

Version:
  $Revision: 1.15 $ $Date: 2000/05/24 22:41:28 $
See Also:
  Serialized Form

Field Summary
`private JServServletManager` | `context` The session context
`protected long` | `creationTime` The time at which this session has been created
`protected java.lang.String` | `id` The session id
`private boolean` | `isNew` Is this session new
`protected long` | `lastAccessTime` The last time the session was accessed.
`private java.util.Hashtable` | `sessionData` The session data
`private boolean` | `valid` Is this session valid

Constructor Summary
`JServSession(java.lang.String id, JServServletManager context)` Creates a new session.

Method Summary
`void` | `access()` Tells the session that it has been accessed
`private void` | `checkState()` Throws an IllegalStateException when the session is no longer valid.
`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.
`javax.servlet.http.HttpSessionContext` | `getSessionContext()` Returns the context in which this session is bound.
`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()` Returns an array of the names of all the application layer data objects bound into the session.
`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.
`boolean` | `isValid()` Has the session been invalidated.
`private void` | `log(java.lang.String channel, java.lang.String msg, java.lang.Throwable t)` Logs an exception report to the servlet log file.
`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.
`private void` | `readObject(java.io.ObjectInputStream stream)` Read the instance variables for this object from the specified object input stream.
`void` | `removeValue(java.lang.String name)` Removes the object bound to the given name in the session's application layer data.
`(package private) void` | `setSessionContext(JServServletManager context)` Sets the context in which this session is bound.
`private void` | `writeObject(java.io.ObjectOutputStream stream)` Write the instance variables for this object to the specified object output stream.

Methods inherited from class java.lang.Object
`, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait`

Field Detail

### id

    protected java.lang.String id

  The session id

### creationTime

    protected long creationTime

  The time at which this session has been created

### lastAccessTime

    protected long lastAccessTime

  The last time the session was accessed.

### sessionData

    private java.util.Hashtable sessionData

  The session data

### context

    private JServServletManager context

  The session context

### valid

    private boolean valid

  Is this session valid

### isNew

    private boolean isNew

  Is this session new

Constructor Detail

### JServSession

    public JServSession(java.lang.String id,
                        JServServletManager context)

  Creates a new session.
  Parameters:
    `id` - The id of the session.
    `context` - The context of the session.

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:
    IllegalStateException - if an attempt is made to access session data after the session has been invalidated

### getSessionContext

    public javax.servlet.http.HttpSessionContext getSessionContext()

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

### setSessionContext

    void setSessionContext(JServServletManager context)

  Sets the context in which this session is bound.

  This is used by JServServletManager.init() to restore the contexts to the sessions after they have been serialized out.

### 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:
    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.

  This information is particularly useful in session management policies. For example,

  - a session manager could leave all sessions which have not been used in a long time in a given context.
  - the sessions can be sorted according to age to optimize some task.
  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:
    IllegalStateException - if an attempt is made to access session data after the session has been invalidated

### 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:
    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:
    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:
    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:
    IllegalStateException - if an attempt is made to access session data after the session has been invalidated

### getValueNames

    public java.lang.String[] getValueNames()

  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:
    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

### isValid

    public boolean isValid()

  Has the session been invalidated.

### access

    public void access()

  Tells the session that it has been accessed

### checkState

    private void checkState()

  Throws an IllegalStateException when the session is no longer valid.

### log

    private void log(java.lang.String channel,
                     java.lang.String msg,
                     java.lang.Throwable t)

  Logs an exception report to the servlet log file.
  Parameters:
    `msg` - The message to be written
    `t` - The exception to be written

### readObject

    private void readObject(java.io.ObjectInputStream stream)
                     throws java.lang.ClassNotFoundException,
                            java.io.IOException

  Read the instance variables for this object from the specified object input stream.
  Parameters:
    `stream` - The stream from which to read
  Throws:
    java.lang.ClassNotFoundException - if a required class cannot be found while deserializing
    java.io.IOException - if an input error occurs while reading

### writeObject

    private void writeObject(java.io.ObjectOutputStream stream)
                      throws java.io.IOException

  Write the instance variables for this object to the specified object output stream.
  Parameters:
    `stream` - The stream on which to write
  Throws:
    java.io.IOException - if an output error occurs while writing

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD