org.apache.tapestry5.services
Interface Session

All Known Implementing Classes:
ClusteredSessionImpl, PageTesterSession, SessionImpl

public interface Session

Generic version of HttpSession, used to bridge the gaps between the Servlet API and the Portlet API.


Method Summary
 Object getAttribute(String name)
          Returns the value previously stored in the session.
 List<String> getAttributeNames()
          Returns a list of the names of all attributes stored in the session.
 List<String> getAttributeNames(String prefix)
          Returns a list of the names of all attributes stored in the session whose name has the provided prefix.
 int getMaxInactiveInterval()
          Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses.
 void invalidate()
          Invalidates this session then unbinds any objects bound to it.
 boolean isInvalidated()
          Checks to see if the session has been invalidated.
 void restoreDirtyObjects()
          Re-stores dirty objects back into the session.
 void setAttribute(String name, Object value)
          Sets the value of an attribute.
 void setMaxInactiveInterval(int seconds)
          Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.
 

Method Detail

getAttributeNames

List<String> getAttributeNames()
Returns a list of the names of all attributes stored in the session. The names are returned sorted alphabetically.


getAttributeNames

List<String> getAttributeNames(String prefix)
Returns a list of the names of all attributes stored in the session whose name has the provided prefix. The names are returned in alphabetical order.


getAttribute

Object getAttribute(String name)
Returns the value previously stored in the session.


setAttribute

void setAttribute(String name,
                  Object value)
Sets the value of an attribute. If the value is null, then the attribute is deleted.


getMaxInactiveInterval

int getMaxInactiveInterval()
Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses. After this interval, the servlet container will invalidate the session. The maximum time interval can be set with the setMaxInactiveInterval method. A negative time indicates the session should never timeout.


setMaxInactiveInterval

void setMaxInactiveInterval(int seconds)
Specifies the time, in seconds, between client requests before the servlet container will invalidate this session. A negative time indicates the session should never timeout.


invalidate

void invalidate()
Invalidates this session then unbinds any objects bound to it.

Throws:
IllegalStateException - if this method is called on an already invalidated session

isInvalidated

boolean isInvalidated()
Checks to see if the session has been invalidated. Note: since 5.3 this will also catch calls to HttpSession.invalidate().

Since:
5.1.0.0

restoreDirtyObjects

void restoreDirtyObjects()
Re-stores dirty objects back into the session. This is necessary to support clustering, because (in most application servers) session objects are only broadcast around the cluster from setAttribute(). If a mutable session object is read and changed, those changes will be limited to a single server in the cluster, which can cause confusing application failures in the event of a failover. Does nothing if there are no changes, or the session has been invalidated.

Since:
5.1.0.0
See Also:
OptimizedSessionPersistedObject, OptimizedSessionPersistedObjectAnalyzer, ImmutableSessionPersistedObject


Copyright © 2003-2012 The Apache Software Foundation.