CPPSERV


Home Projects Jobs Clientele Contact
CPPSERV Documentation Download TODO Mailing lists Bug tracker News RSS Feed Browse source

container::HttpSessionImpl Class Reference

#include <HttpSessionImpl.h>

Inheritance diagram for container::HttpSessionImpl:
Collaboration diagram for container::HttpSessionImpl:

List of all members.


Public Member Functions

 HttpSessionImpl (servlet::ServletContext &ctx, const std::string &id, time_t timeout)
virtual ~HttpSessionImpl ()
void notNew ()
bool validP () const
virtual long getCreationTime () const
virtual long getLastAccessedTime () const
virtual const
servlet::ServletContext
getServletContext () const
virtual void setMaxInactiveInterval (int interval)
virtual int getMaxInactiveInterval () const
virtual boost::shared_ptr< void > getAttribute (const std::string &name)
virtual std::auto_ptr
< std::vector< std::string > > 
getAttributeNames () const
virtual void setAttribute (const std::string &name, boost::shared_ptr< void > value)
virtual bool hasAttribute (const std::string &name) const
virtual void removeAttribute (const std::string &name)
virtual void invalidate ()
virtual bool isNew () const
virtual std::string getId () const

Private Types

typedef std::map< std::string,
boost::shared_ptr< void > > 
attr_t

Private Attributes

attr_t m_attrs
int m_maxInactiveInterval
time_t m_creationTime
time_t m_lastAccessTime
servlet::ServletContextm_servletContext
std::string m_id
bool m_isNew
bool m_isValid

Detailed Description

Author:
Ilya A. Volynets-Evenbakh

Definition at line 34 of file HttpSessionImpl.h.


Member Typedef Documentation

typedef std::map<std::string,boost::shared_ptr<void> > container::HttpSessionImpl::attr_t [private]

Definition at line 37 of file HttpSessionImpl.h.


Constructor & Destructor Documentation

container::HttpSessionImpl::HttpSessionImpl ( servlet::ServletContext ctx,
const std::string &  id,
time_t  timeout 
)

Definition at line 26 of file HttpSessionImpl.cpp.

References m_creationTime, and m_lastAccessTime.

container::HttpSessionImpl::~HttpSessionImpl (  )  [virtual]

Definition at line 38 of file HttpSessionImpl.cpp.


Member Function Documentation

boost::shared_ptr< void > container::HttpSessionImpl::getAttribute ( const std::string &  name  )  [virtual]

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

Parameters:
name a string specifying the name of the object
Returns:
the object with the specified name
Exceptions:
IllegalStateException if this method is called on an invalidated session

Implements servlet::HttpSession.

Definition at line 62 of file HttpSessionImpl.cpp.

References m_attrs.

std::auto_ptr< std::vector< std::string > > container::HttpSessionImpl::getAttributeNames (  )  const [virtual]

Returns an Enumeration of String objects containing the names of all the objects bound to this session.

Returns:
an Enumeration of String objects specifying the names of all the objects bound to this session
Exceptions:
IllegalStateException if this method is called on an invalidated session

Implements servlet::HttpSession.

Definition at line 70 of file HttpSessionImpl.cpp.

References container::util::getMapKeyNames(), and m_attrs.

Here is the call graph for this function:

long container::HttpSessionImpl::getCreationTime (  )  const [virtual]

Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.

Returns:
a long specifying when this session was created, expressed in milliseconds since 1/1/1970 GMT
Exceptions:
IllegalStateException if this method is called on an invalidated session

Implements servlet::HttpSession.

Definition at line 42 of file HttpSessionImpl.cpp.

References m_creationTime.

std::string container::HttpSessionImpl::getId (  )  const [virtual]

Returns a string containing the unique identifier assigned to this session. The identifier is assigned by the servlet container and is implementation dependent.

Returns:
a string specifying the identifier assigned to this session
Exceptions:
IllegalStateException if this method is called on an invalidated session

Implements servlet::HttpSession.

Definition at line 98 of file HttpSessionImpl.cpp.

References m_id.

long container::HttpSessionImpl::getLastAccessedTime (  )  const [virtual]

Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT, and marked by the time the container received the request.

Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.

Returns:
a long representing the last time the client sent a request associated with this session, expressed in milliseconds since 1/1/1970 GMT
Exceptions:
IllegalStateException if this method is called on an invalidated session

Implements servlet::HttpSession.

Definition at line 47 of file HttpSessionImpl.cpp.

References m_lastAccessTime.

int container::HttpSessionImpl::getMaxInactiveInterval (  )  const [virtual]

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.

Returns:
an integer specifying the number of seconds this session remains open between client requests
See also:
setMaxInactiveInterval

Implements servlet::HttpSession.

Definition at line 57 of file HttpSessionImpl.cpp.

References m_maxInactiveInterval.

const servlet::ServletContext & container::HttpSessionImpl::getServletContext (  )  const [virtual]

Returns the ServletContext to which this session belongs.

Returns:
The ServletContext object for the web application
Since:
2.3

Implements servlet::HttpSession.

Definition at line 52 of file HttpSessionImpl.cpp.

References m_servletContext.

bool container::HttpSessionImpl::hasAttribute ( const std::string &  name  )  const [virtual]

[C++ Servlet API Extention]

Returns false if no attribute of the given name exists. Returns true otherwize

Parameters:
name a String specifying the name of the attribute
Returns:
false if the attribute does not exist. true otherwize

Implements servlet::HttpSession.

Definition at line 108 of file HttpSessionImpl.cpp.

References m_attrs.

void container::HttpSessionImpl::invalidate (  )  [virtual]

Invalidates this session then unbinds any objects bound to it.

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

Implements servlet::HttpSession.

Definition at line 88 of file HttpSessionImpl.cpp.

References m_isValid.

bool container::HttpSessionImpl::isNew (  )  const [virtual]

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.

Returns:
true if the server has created a session, but the client has not yet joined
Exceptions:
IllegalStateException if this method is called on an already invalidated session

Implements servlet::HttpSession.

Definition at line 93 of file HttpSessionImpl.cpp.

References m_isNew.

container::HttpSessionImpl::notNew (  )  [inline]

This method is called when session is connected to second request (i.e. request that sent session cookie)

Definition at line 55 of file HttpSessionImpl.h.

References m_isNew, and m_lastAccessTime.

Referenced by container::serverconfig::AppContext::getSession().

void container::HttpSessionImpl::removeAttribute ( const std::string &  name  )  [virtual]

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. The container then notifies any HttpSessionAttributeListeners in the web application.

Parameters:
name the name of the object to remove from this session
Exceptions:
IllegalStateException if this method is called on an invalidated session

Implements servlet::HttpSession.

Definition at line 80 of file HttpSessionImpl.cpp.

References m_attrs.

void container::HttpSessionImpl::setAttribute ( const std::string &  name,
boost::shared_ptr< void >  value 
) [virtual]

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 new object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueBound. The container then notifies any HttpSessionAttributeListeners in the web application.

If an object was already bound to this session of this name that implements HttpSessionBindingListener, its HttpSessionBindingListener.valueUnbound method is called.

If the value passed in is null, this has the same effect as calling removeAttribute().

Parameters:
name the name to which the object is bound; cannot be null
value the object to be bound
Exceptions:
IllegalStateException if this method is called on an invalidated session

Implements servlet::HttpSession.

Definition at line 75 of file HttpSessionImpl.cpp.

References m_attrs.

void container::HttpSessionImpl::setMaxInactiveInterval ( int  interval  )  [virtual]

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.

Parameters:
interval An integer specifying the number of seconds

Implements servlet::HttpSession.

Definition at line 103 of file HttpSessionImpl.cpp.

References m_maxInactiveInterval.

container::HttpSessionImpl::validP (  )  const [inline]


Member Data Documentation

Definition at line 40 of file HttpSessionImpl.h.

Referenced by getCreationTime(), and HttpSessionImpl().

std::string container::HttpSessionImpl::m_id [private]

Definition at line 42 of file HttpSessionImpl.h.

Referenced by getId().

Definition at line 43 of file HttpSessionImpl.h.

Referenced by isNew(), and notNew().

Definition at line 44 of file HttpSessionImpl.h.

Referenced by invalidate(), and validP().


The documentation for this class was generated from the following files:

SourceForge.net Logo