The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Wombat::Core::Session - internal session class

SYNOPSIS

DESCRIPTION

Core implementation of Wombat::Session and Servlet::Http::HttpSession.

CONSTRUCTOR

new()

Construct and return a Wombat::Core::Session instance, initializing fields appropriately.

  $self->SUPER::new();

ACCESSOR METHODS

getAttribute($name)

Returns the object bound with the specified name in this session, or undef if no object is bound under the name.

Parameters:

$name

the name of the object

Throws:

Servlet::Util::IllegalStateException

if this method is called on an invalidated session

getAttributeNames()

Returns an array containing the names of all the objects bound to this session, or an empty array if there are no bound objects.

Throws:

Servlet::Util::IllegalStateException

if this method is called on an invalidated session

removeAttribute($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 Servlet::Http::HttpSessionBindingListener, the container calls valueUnbound() on the object.

Parameters:

$name

the name of the object

Throws:

Servlet::Util::IllegalStateException

if this method is called on an invalidated session

setAttribute($name, $value)

Binds an object to this session using the specified name. 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 Servlet::Http::HttpSessionBindingListener, the container calls valueBound() on the object.

If a previously bound object was replaced, and it implements Servlet::Http::HttpSessionBindingListener, the container calls valueUnbound() on it.

Parameters:

$name

the name to which the object is bound

$value

the object to be bound

Throws:

Servlet::Util::IllegalStateException

if this method is called on an invalidated session

getAuthType()

Return the authentication type used to authenticate the cached principal, if any.

setAuthType($authType)

Set the authentication type used to authenticate the cached principal, if any.

Parameters:

$authType

the authentication type

getCreationTime()

Return the creation time for this Session, in seconds since the epoch.

Throws:

Servlet::Util::IllegalStateException

if this method is called on an invalidated session

setCreationTime(time)

Set the creation time for this Session. This method is called by the SessionManager when a Session instance is created or an existing Session instance is reused.

Parameters:

$time

the creation time, in seconds since the epoch

getId()

Return the session identifier for this Session.

setId($id)

Set the session identifier for this Session.

Parameters:

$id

the session identifier

getLastAccessedTime()

Return the last time the client sent a request associated with this Session, as the number of seconds since the epoch. Actions taken by servlet applications do not affect the last accessed time.

getMaxInactiveInterval()

Return the maximum inactive interval, in seconds, between client requests before the servlet container will invalidate this Session. A negative itnerval indicates that the session should never be invalidated.

setMaxInactiveInterval($interval)

Set the maximum inactive interval for the Session.

Parameters:

$interval

the new interval, in seconds

isNew()

Returns true if the client does not yet know about the session or if the client chooses not to join the session. For example, if the server used only cookie-based sessions, and the client had disabled the use of cookies, then a session would be new on each request.

Throws:

Servlet::Util::IllegalStateException

if this method is called on an invalidated session

setNew($flag)

Set a flag specifying whether or not the session is newly created.

Parameters:

$flag

the boolean value to set

getPrincipal()

Return the authenticated principal for this Session, or undef if there is none.

setPrincipal($principal)

Set the authenticated principal for this Session.

Parameters:

$principal

the new principal

getSession()

Return the HttpSession which acts as a facade for this Session to servlet applications.

getSessionManager()

Return the SessionManager which manages this Session.

setSessionManager($manager)

Set the SessionManager which manages this Session.

Parameters:

$manager

the Wombat::SessionManager

isValid()

Return a flag specifying whether or not the session is valid.

setValid($flag)

Set a flag specifying whether or not the session is valid.

Parameters:

$flag

the boolean value to set

PUBLIC METHODS

access()

Update the accessed time information for this Session. This method should be called by the Application when processing a Request, even if the Application does not reference it.

expire()

Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.

invalidate()

Invalidates this session, then unbinds any objects bound to it.

Throws:

Servlet::Util::IllegalStateException

if this method is called on an invalidated session

recycle()

Release all object references and initialize instances variables in preparation for use or reuse of this object.

SEE ALSO

Wombat::Session, Wombat::SessionManager

AUTHOR

Brian Moseley, bcm@maz.org