#include <HttpSessionImpl.h>
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::ServletContext & | m_servletContext |
std::string | m_id |
bool | m_isNew |
bool | m_isValid |
Definition at line 34 of file HttpSessionImpl.h.
typedef std::map<std::string,boost::shared_ptr<void> > container::HttpSessionImpl::attr_t [private] |
Definition at line 37 of file HttpSessionImpl.h.
container::HttpSessionImpl::HttpSessionImpl | ( | servlet::ServletContext & | ctx, | |
const std::string & | id, | |||
time_t | timeout | |||
) |
container::HttpSessionImpl::~HttpSessionImpl | ( | ) | [virtual] |
Definition at line 38 of file HttpSessionImpl.cpp.
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.
name | a string specifying the name of the object |
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.
Enumeration
of String
objects specifying the names of all the objects bound to this sessionIllegalStateException | 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.
long container::HttpSessionImpl::getCreationTime | ( | ) | const [virtual] |
Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.
long
specifying when this session was created, expressed in milliseconds since 1/1/1970 GMTIllegalStateException | 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.
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.
long
representing the last time the client sent a request associated with this session, expressed in milliseconds since 1/1/1970 GMTIllegalStateException | 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.
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.
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
name | a String specifying the name of the attribute |
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.
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.
true
if the server has created a session, but the client has not yet joinedIllegalStateException | 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 HttpSessionAttributeListener
s in the web application.
name | the name of the object to remove from this session |
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 HttpSessionAttributeListener
s 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()
.
name | the name to which the object is bound; cannot be null | |
value | the object to be bound |
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.
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] |
Definition at line 64 of file HttpSessionImpl.h.
References m_isValid, m_lastAccessTime, and m_maxInactiveInterval.
Referenced by container::HttpServletRequestImpl::isRequestedSessionIdValid().
attr_t container::HttpSessionImpl::m_attrs [private] |
Definition at line 38 of file HttpSessionImpl.h.
Referenced by getAttribute(), getAttributeNames(), hasAttribute(), removeAttribute(), and setAttribute().
time_t container::HttpSessionImpl::m_creationTime [private] |
Definition at line 40 of file HttpSessionImpl.h.
Referenced by getCreationTime(), and HttpSessionImpl().
std::string container::HttpSessionImpl::m_id [private] |
bool container::HttpSessionImpl::m_isNew [private] |
bool container::HttpSessionImpl::m_isValid [private] |
time_t container::HttpSessionImpl::m_lastAccessTime [private] |
Definition at line 40 of file HttpSessionImpl.h.
Referenced by getLastAccessedTime(), HttpSessionImpl(), notNew(), and validP().
int container::HttpSessionImpl::m_maxInactiveInterval [private] |
Definition at line 39 of file HttpSessionImpl.h.
Referenced by getMaxInactiveInterval(), setMaxInactiveInterval(), and validP().