1 16 17 package org.apache.axis.session; 18 19 import java.util.Enumeration ; 20 import java.util.Hashtable ; 21 22 27 public class SimpleSession implements Session 28 { 29 private Hashtable rep = null; 30 31 34 private int timeout = -1; 35 private long lastTouched; 36 37 40 public SimpleSession() 41 { 42 lastTouched = System.currentTimeMillis(); 43 } 44 45 49 public Object get(String key) 50 { 51 if (rep == null) 52 return null; 53 lastTouched = System.currentTimeMillis(); 54 return rep.get(key); 55 } 56 57 62 public void set(String key, Object value) 63 { 64 synchronized (this) { 65 if (rep == null) 66 rep = new Hashtable (); 67 } 68 lastTouched = System.currentTimeMillis(); 69 rep.put(key, value); 70 } 71 72 76 public void remove(String key) 77 { 78 if (rep != null) 79 rep.remove(key); 80 lastTouched = System.currentTimeMillis(); 81 } 82 83 86 public Enumeration getKeys() { 87 if (rep != null) 88 return rep.keys(); 89 return null; 90 } 91 92 98 public void setTimeout(int timeout) 99 { 100 this.timeout = timeout; 101 } 102 103 public int getTimeout() 104 { 105 return timeout; 106 } 107 108 111 public void touch() { 112 lastTouched = System.currentTimeMillis(); 113 } 114 115 118 public void invalidate() { 119 rep = null; 120 lastTouched = System.currentTimeMillis(); 121 timeout = -1; 122 } 123 124 public long getLastAccessTime() 125 { 126 return lastTouched; 127 } 128 129 137 public synchronized Object getLockObject() { 138 if (rep == null) { 139 rep = new Hashtable (); 140 } 141 return rep; 142 } 143 } 144 | Popular Tags |