pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.service.request
Class HttpBoundSession

java.lang.Object
  extended by org.torweg.pulse.service.request.HttpBoundSession
All Implemented Interfaces:
java.io.Serializable, java.util.EventListener, javax.servlet.http.HttpSessionBindingListener, JDOMable, ServiceSession

public final class HttpBoundSession
extends java.lang.Object
implements ServiceSession, javax.servlet.http.HttpSessionBindingListener

The HttpBoundSession associated with the request to the pulse service.

Version:
$Revision: 1741 $
Author:
Thomas Weber
See Also:
Serialized Form

Method Summary
 void addSessionRole(Role role)
          Adds the given Role as session role.
 org.jdom.Element deserializeToJDOM()
          Returns a JDOM representation of the ServiceSession.
 java.io.Serializable getAttribute(java.lang.String name)
          returns the Serializable bound with the specified name in this ServiceSession, or <strong>null</strong> if no Serializable is bound under the name.
 java.util.Set<java.lang.String> getAttributeNames()
          returns a List with the attribute names of this ServiceSession.
 long getCreationTime()
          get the time when this ServiceSession was created, measured in milliseconds since midnight January 1, 1970 GMT.
 byte[] getSecret()
          returns the session's secret.
static ServiceSession getSession()
          returns a dummy HttpBoundSession which is not bound to the HttpSession.
static HttpBoundSession getSession(javax.servlet.http.HttpServletRequest req)
          get the HttpBoundSession that is registered to the given HttpServletRequest.
 java.util.Set<Role> getSessionRoles()
          Returns the Roles valid only for the session.
 boolean hasState()
          returns whether the ServiceSession has a different state than upon creation.
 boolean isBound()
          returns whether the ServiceSession is actually bound to the underlying session management.
 void removeAttribute(java.lang.String name)
          removes an attribute from the ServiceSession.
 void setAttribute(java.lang.String name, java.io.Serializable value)
          add an attribute to the ServiceSession.
 void valueBound(javax.servlet.http.HttpSessionBindingEvent arg0)
           
 void valueUnbound(javax.servlet.http.HttpSessionBindingEvent arg0)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSession

public static HttpBoundSession getSession(javax.servlet.http.HttpServletRequest req)
get the HttpBoundSession that is registered to the given HttpServletRequest.

Parameters:
req - the request
Returns:
the associated session

getSession

public static ServiceSession getSession()
returns a dummy HttpBoundSession which is not bound to the HttpSession.

Returns:
a dummy HttpBoundSession which is not bound to the HttpSession

isBound

public boolean isBound()
returns whether the ServiceSession is actually bound to the underlying session management.

Specified by:
isBound in interface ServiceSession
Returns:
true, if and only if the ServiceSession is bound to the HttpSession. Otherwise false.

hasState

public boolean hasState()
returns whether the ServiceSession has a different state than upon creation.

Specified by:
hasState in interface ServiceSession
Returns:
true, if and only if the ServiceSession has a different state than upon creation. Otherwise false.

getAttribute

public java.io.Serializable getAttribute(java.lang.String name)
Description copied from interface: ServiceSession
returns the Serializable bound with the specified name in this ServiceSession, or <strong>null</strong> if no Serializable is bound under the name.

Specified by:
getAttribute in interface ServiceSession
Parameters:
name - the name of the attribute to fetch
Returns:
the desired attribute or null, if no such attribute has been stored in the session
See Also:
ServiceSession.getAttribute(java.lang.String)

getAttributeNames

public java.util.Set<java.lang.String> getAttributeNames()
Description copied from interface: ServiceSession
returns a List with the attribute names of this ServiceSession.

Specified by:
getAttributeNames in interface ServiceSession
Returns:
the names of all session attributes
See Also:
ServiceSession.getAttributeNames()

getCreationTime

public long getCreationTime()
Description copied from interface: ServiceSession
get the time when this ServiceSession was created, measured in milliseconds since midnight January 1, 1970 GMT.

Specified by:
getCreationTime in interface ServiceSession
Returns:
the creation time of the session in milliseconds since the epoch
See Also:
ServiceSession.getCreationTime()

setAttribute

public void setAttribute(java.lang.String name,
                         java.io.Serializable value)
Description copied from interface: ServiceSession
add an attribute to the ServiceSession.

Any previously added attributes of the same name will be removed from the ServiceSession and be replaced by the specified value.

Specified by:
setAttribute in interface ServiceSession
Parameters:
name - the name of the attribute to be set
value - the value of the attribute to be set
See Also:
ServiceSession.setAttribute(java.lang.String, java.io.Serializable)

removeAttribute

public void removeAttribute(java.lang.String name)
Description copied from interface: ServiceSession
removes an attribute from the ServiceSession.

Specified by:
removeAttribute in interface ServiceSession
Parameters:
name - the name of the attribute to be removed
See Also:
ServiceSession.removeAttribute(java.lang.String)

valueBound

public void valueBound(javax.servlet.http.HttpSessionBindingEvent arg0)
Specified by:
valueBound in interface javax.servlet.http.HttpSessionBindingListener
Parameters:
arg0 - is completely ignored
See Also:
HttpSessionBindingListener.valueBound(javax.servlet.http.HttpSessionBindingEvent)

valueUnbound

public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent arg0)
Specified by:
valueUnbound in interface javax.servlet.http.HttpSessionBindingListener
Parameters:
arg0 - is completely ignored
See Also:
HttpSessionBindingListener.valueUnbound(javax.servlet.http.HttpSessionBindingEvent)

getSecret

public byte[] getSecret()
returns the session's secret.

Specified by:
getSecret in interface ServiceSession
Returns:
the secret
See Also:
ServiceSession.getSecret()

addSessionRole

public void addSessionRole(Role role)
Adds the given Role as session role.

Specified by:
addSessionRole in interface ServiceSession
Parameters:
role - the Role to add

getSessionRoles

public java.util.Set<Role> getSessionRoles()
Returns the Roles valid only for the session.

Specified by:
getSessionRoles in interface ServiceSession
Returns:
the sessionRoles

deserializeToJDOM

public org.jdom.Element deserializeToJDOM()
Returns a JDOM representation of the ServiceSession.

JDOMable values will be expanded, other values will be represented by their toString()-methods.

Specified by:
deserializeToJDOM in interface JDOMable
Returns:
a JDOM representation of the ServiceSession.