1 16 17 package org.apache.jetspeed.services.webpage; 18 19 import java.util.HashMap ; 21 import java.util.Iterator ; 22 23 import javax.servlet.http.*; 25 26 import org.apache.log4j.Logger; 27 28 37 38 public class SessionMap extends HashMap implements HttpSessionBindingListener 39 { 40 41 private String sessionUser; 43 44 private String sessionID; 46 47 private boolean active = true; 49 50 private int hitCount = 0; 52 53 private int cacheCount = 0; 55 56 static Logger log = Logger.getLogger(SessionMap.class); 57 58 65 public SessionMap(String sessionID, String sessionUser) 66 { 67 this.sessionID = sessionID; 68 this.sessionUser = sessionUser; 69 } 70 71 72 77 public String getUser() 78 { 79 return sessionUser; 80 } 81 82 87 public String getSessionID() 88 { 89 return sessionID; 90 } 91 92 97 public String getSessionState() 98 { 99 return (active) ? "active" : "inactive"; 100 } 101 102 107 public int getSessionCount() 108 { 109 return this.size(); 110 } 111 112 117 public int getHitCount() 118 { 119 return hitCount; 120 } 121 122 126 public void incHitCount() 127 { 128 hitCount++; 129 } 130 131 136 public int getCacheCount() 137 { 138 return cacheCount; 139 } 140 141 145 public void incCacheCount() 146 { 147 cacheCount++; 148 } 149 150 151 156 public void valueBound(HttpSessionBindingEvent event) 157 { 158 } 159 160 168 public void valueUnbound(HttpSessionBindingEvent event) 169 { 170 log.info("~~~ SessionMap UNBOUND as " + event.getName() + " from " + event.getSession().getId() ); 171 172 Iterator it = values().iterator(); 174 while (it.hasNext()) 175 { 176 SiteSession hps = (SiteSession)it.next(); 177 try 178 { 179 hps.logout(null); 180 181 } catch(Exception e) 182 { 183 log.error("Unbound-Logout of Session: " + e); 185 } 186 } 187 active = false; 188 clear(); 189 } 190 191 192 } 193 | Popular Tags |