org.liquidsite.core.web
Class RequestSession

java.lang.Object
  extended byorg.liquidsite.core.web.RequestSession

public class RequestSession
extends java.lang.Object

An HTTP session.


Constructor Summary
RequestSession(javax.servlet.http.HttpSession session)
          Creates a new request session.
 
Method Summary
 void addFile(java.lang.String name, java.io.File file)
          Adds a file to the session.
static int getActiveCount()
          Returns the number of currently active sessions.
 java.util.Map getAllFiles()
          Returns a map of all session files.
 java.lang.Object getAttribute(java.lang.String name)
          Returns the value of a session attribute.
 java.lang.Object getAttribute(java.lang.String name, java.lang.Object defVal)
          Returns the value of a session attribute.
 java.io.File getFile(java.lang.String name)
          Returns a session file with a specified name.
 User getUser()
          Returns the session user.
 void invalidate()
          Invalidates this session.
 void removeAllFiles()
          Removes all files from the session.
 void removeFile(java.lang.String name)
          Removes a file from the session.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Sets a session attribute value.
 void setUser(User user)
          Sets the session user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestSession

public RequestSession(javax.servlet.http.HttpSession session)
Creates a new request session.

Parameters:
session - the request session
Method Detail

getActiveCount

public static int getActiveCount()
Returns the number of currently active sessions.

Returns:
the number of active sessions

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the value of a session attribute.

Parameters:
name - the attribute name
Returns:
the attribute value, or null if no such attribute was found

getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     java.lang.Object defVal)
Returns the value of a session attribute. If the specified attribute does not exist, a default value will be returned.

Parameters:
name - the attribute name
defVal - the default attribute value
Returns:
the attribute value, or the default value if no such attribute was found

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Sets a session attribute value.

Parameters:
name - the attribute name
value - the attribute value, or null to remove

getFile

public java.io.File getFile(java.lang.String name)
Returns a session file with a specified name.

Parameters:
name - the file name
Returns:
the session file found, or null if no such file exists in the session

getAllFiles

public java.util.Map getAllFiles()
Returns a map of all session files. The files are indexed by their file names.

Returns:
a map of all session files

addFile

public void addFile(java.lang.String name,
                    java.io.File file)
Adds a file to the session. After this point, the file will be managed by the session, meaning that the session is responsable for deleting the file once it is no longer accessible.

Parameters:
name - the file name
file - the file to add

removeFile

public void removeFile(java.lang.String name)
Removes a file from the session.

Parameters:
name - the file name

removeAllFiles

public void removeAllFiles()
Removes all files from the session.


getUser

public User getUser()
Returns the session user. The session user is null until it is set by the setUser() method. Normally the session user is not set until the user has been authenticated.

Returns:
the session user, or null if no user has been set
See Also:
setUser(org.liquidsite.core.content.User)

setUser

public void setUser(User user)
Sets the session user. The session user is null until it is set by this method. Normally the session user is not set until the user has been authenticated.

Parameters:
user - the new session user
See Also:
getUser()

invalidate

public void invalidate()
Invalidates this session. This method will remove any files still in the session. After calling this method, no other methods in this class should be called, as their results would be unpredictable.