FileDocCategorySizeDatePackage
SimpleSession.javaAPI DocApache Axis 1.43752Sat Apr 22 18:57:28 BST 2006org.apache.axis.session

SimpleSession

public class SimpleSession extends Object implements Session
A trivial session implementation.
author
Glen Daniels (gdaniels@apache.org)

Fields Summary
private Hashtable
rep
private int
timeout
Inactivity timeout (in seconds). Not used yet.
private long
lastTouched
Constructors Summary
public SimpleSession()
Default constructor - set lastTouched to now

    
                 
     
    
        lastTouched = System.currentTimeMillis();
    
Methods Summary
public java.lang.Objectget(java.lang.String key)
Get a property from the session

param
key the name of the property desired.

        if (rep == null)
            return null;
        lastTouched = System.currentTimeMillis();
        return rep.get(key);
    
public java.util.EnumerationgetKeys()
Get an enumeration of the keys in this session

        if (rep != null)
            return rep.keys();
        return null;
    
public longgetLastAccessTime()

        return lastTouched;
    
public synchronized java.lang.ObjectgetLockObject()
Get an Object suitable for synchronizing the session. This method exists because different session implementations might provide different ways of getting at shared data. For a simple hashtable- based session, this would just be the hashtable, but for sessions which use database connections, etc. it might be an object wrapping a table ID or somesuch.

        if (rep == null) {
            rep = new Hashtable();
        }
        return rep;
    
public intgetTimeout()

        return timeout;
    
public voidinvalidate()
invalidate the session

        rep = null;
        lastTouched = System.currentTimeMillis();
        timeout = -1;        
    
public voidremove(java.lang.String key)
Remove a property from the session

param
key the name of the property desired.

        if (rep != null)
            rep.remove(key);
        lastTouched = System.currentTimeMillis();
    
public voidset(java.lang.String key, java.lang.Object value)
Set a property in the session

param
key the name of the property to set.
param
value the value of the property.

        synchronized (this) {
            if (rep == null)
                rep = new Hashtable();
        }
        lastTouched = System.currentTimeMillis();
        rep.put(key, value);
    
public voidsetTimeout(int timeout)
Set the session's time-to-live. This is implementation-specific, but basically should be the # of seconds of inactivity which will cause the session to time out and invalidate. "inactivity" is implementation-specific.

        this.timeout = timeout;
    
public voidtouch()
"Touch" the session (mark it recently used)

        lastTouched = System.currentTimeMillis();