org.norther.tammi.spray.session
Class DefaultSession

java.lang.Object
  extended by org.norther.tammi.core.pool.RecyclableSupport
      extended by org.norther.tammi.core.pool.PoolableSupport
          extended by org.norther.tammi.spray.session.DefaultSession
All Implemented Interfaces:
Serializable, EventListener, HttpSession, CacheListener, Manageable, Poolable, Recyclable, AuthenticatedSession

public class DefaultSession
extends PoolableSupport
implements AuthenticatedSession, CacheListener, Manageable

A default implementation of AuthenticatdSession.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
DefaultSession(MBeanReference mgr, String id)
          Constructs a new session.
 
Method Summary
 void access()
          Updates the accessed time information for this session.
 void activate()
          Activates session attributes.
 void activated(CachedEntryEvent event)
          Notifies the object that it has been activated to the cache.
 void dispose()
          Disposes the object by setting its disposed flag.
 void disposed()
          A call back indicating that this instance is not needed any more and can be disposed.
 void expired(CachedEntryEvent event)
          Notifies the object that it has been expired from the cache.
 Object getAttribute(String name)
           
 Enumeration getAttributeNames()
           
 long getCreationTime()
           
 String getId()
           
 long getLastAccessedTime()
           
 int getMaxInactiveInterval()
           
 ServletContext getServletContext()
           
 HttpSessionContext getSessionContext()
           
 Principal getUserPrincipal()
          Gets the authenticated principal that is associated with this session.
 Object getValue(String name)
           
 String[] getValueNames()
           
 void invalidate()
           
 boolean isNew()
           
 boolean isValid()
          Checks whether the session is valid.
 void passivate()
          Passivates session attributes.
 void passivated(CachedEntryEvent event)
          Notifies the object that it has been passivated from the cache.
 void postmanaged()
          This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.
 void premanaged(MBeanDelegate adapter)
          This method is called when the implementing adaptee is trying to be managed either during pre-registration of the corresponding adapter MBean or just before it is explicitly added to the adapter MBean during run-time.
 void putValue(String name, Object value)
           
 void recycle(MBeanReference mgr, String id)
          Recycles an existing session with an expiration.
 HttpSession registerUserPrincipal(Principal principal)
          Registers the authenticated principal that is associated with this session or a joined one.
 void removeAttribute(String name)
           
 void removeValue(String name)
           
 void setAttribute(String name, Object value)
           
 void setMaxInactiveInterval(int interval)
           
 String toString()
          Return a string representation of this object.
 void unmanaged()
          This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.
 
Methods inherited from class org.norther.tammi.core.pool.PoolableSupport
recycled
 
Methods inherited from class org.norther.tammi.core.pool.RecyclableSupport
isDisposed, recycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.pool.Recyclable
isDisposed, recycle
 

Constructor Detail

DefaultSession

public DefaultSession(MBeanReference mgr,
                      String id)
Constructs a new session.

Parameters:
mgr - the manager of this session.
id - the id of the session.
Method Detail

recycle

public void recycle(MBeanReference mgr,
                    String id)
Recycles an existing session with an expiration.

Parameters:
mgr - the manager of this session.
id - the id of the session.

dispose

public void dispose()
Description copied from class: RecyclableSupport
Disposes the object by setting its disposed flag.

Specified by:
dispose in interface Recyclable
Overrides:
dispose in class RecyclableSupport

disposed

public void disposed()
Description copied from interface: Poolable
A call back indicating that this instance is not needed any more and can be disposed.

Specified by:
disposed in interface Poolable
Overrides:
disposed in class PoolableSupport

premanaged

public void premanaged(MBeanDelegate adapter)
                throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is trying to be managed either during pre-registration of the corresponding adapter MBean or just before it is explicitly added to the adapter MBean during run-time.

Specified by:
premanaged in interface Manageable
Parameters:
adapter - the managing adapter.
Throws:
Exception - if the adaptee refused to be managed.

postmanaged

public void postmanaged()
Description copied from interface: Manageable
This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.

Specified by:
postmanaged in interface Manageable

unmanaged

public void unmanaged()
               throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.

Specified by:
unmanaged in interface Manageable
Throws:
Exception - if the adaptee refused to be unmanaged.

expired

public void expired(CachedEntryEvent event)
Description copied from interface: CacheListener
Notifies the object that it has been expired from the cache.

Specified by:
expired in interface CacheListener
Parameters:
event - the cached entry event.

passivated

public void passivated(CachedEntryEvent event)
Description copied from interface: CacheListener
Notifies the object that it has been passivated from the cache.

Specified by:
passivated in interface CacheListener
Parameters:
event - the cached entry event.

activated

public void activated(CachedEntryEvent event)
Description copied from interface: CacheListener
Notifies the object that it has been activated to the cache.

Specified by:
activated in interface CacheListener
Parameters:
event - the cached entry event.

isValid

public boolean isValid()
Description copied from interface: AuthenticatedSession
Checks whether the session is valid.

Specified by:
isValid in interface AuthenticatedSession
Returns:
true for a valid session.

getAttribute

public Object getAttribute(String name)
Specified by:
getAttribute in interface HttpSession

setAttribute

public void setAttribute(String name,
                         Object value)
Specified by:
setAttribute in interface HttpSession

removeAttribute

public void removeAttribute(String name)
Specified by:
removeAttribute in interface HttpSession

getAttributeNames

public Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface HttpSession

getId

public String getId()
Specified by:
getId in interface HttpSession

getCreationTime

public long getCreationTime()
Specified by:
getCreationTime in interface HttpSession

getLastAccessedTime

public long getLastAccessedTime()
Specified by:
getLastAccessedTime in interface HttpSession

getMaxInactiveInterval

public int getMaxInactiveInterval()
Specified by:
getMaxInactiveInterval in interface HttpSession

setMaxInactiveInterval

public void setMaxInactiveInterval(int interval)
Specified by:
setMaxInactiveInterval in interface HttpSession

isNew

public boolean isNew()
Specified by:
isNew in interface HttpSession

invalidate

public void invalidate()
Specified by:
invalidate in interface HttpSession

getServletContext

public ServletContext getServletContext()
Specified by:
getServletContext in interface HttpSession

getSessionContext

public HttpSessionContext getSessionContext()
Specified by:
getSessionContext in interface HttpSession

getValue

public Object getValue(String name)
Specified by:
getValue in interface HttpSession

putValue

public void putValue(String name,
                     Object value)
Specified by:
putValue in interface HttpSession

removeValue

public void removeValue(String name)
Specified by:
removeValue in interface HttpSession

getValueNames

public String[] getValueNames()
Specified by:
getValueNames in interface HttpSession

getUserPrincipal

public Principal getUserPrincipal()
Description copied from interface: AuthenticatedSession
Gets the authenticated principal that is associated with this session.

Specified by:
getUserPrincipal in interface AuthenticatedSession
Returns:
the authenticated principal or null if not registered.

registerUserPrincipal

public HttpSession registerUserPrincipal(Principal principal)
Description copied from interface: AuthenticatedSession
Registers the authenticated principal that is associated with this session or a joined one.

Specified by:
registerUserPrincipal in interface AuthenticatedSession
Parameters:
principal - the authenticated principal.
Returns:
the session to which the pricipal was registered.

access

public void access()
Description copied from interface: AuthenticatedSession
Updates the accessed time information for this session. This method should be called by the container when a request comes in for a particular session, even if the application does not reference it.

Specified by:
access in interface AuthenticatedSession

activate

public void activate()
Activates session attributes.


passivate

public void passivate()
Passivates session attributes.


toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class Object
Returns:
the session as a string.


Copyright © 2004 The Norther Organization. All rights reserved.