public class HttpSessionBinding implements javax.servlet.http.HttpSessionBindingListener { ServletContext application = null; public HttpSessionBinding(ServletContext application) { super(); if (application ==null) throw new IllegalArgumentException("Null application is not accept."); this.application = application; } public void valueBound(javax.servlet.http.HttpSessionBindingEvent e) { Vector activeSessions = (Vector) application.getAttribute("activeSessions"); if (activeSessions == null) { activeSessions = new Vector(); } JDBCUser sessionUser = (JDBCUser)e.getSession().getAttribute("user"); if (sessionUser != null) { activeSessions.add(e.getSession()); } application.setAttribute("activeSessions",activeSessions); } public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent e) { JDBCUser sessionUser = (JDBCUser)e.getSession().getAttribute("user"); if (sessionUser == null) { Vector activeSessions = (Vector) application.getAttribute("activeSessions"); if (activeSessions != null) { activeSessions.remove(e.getSession().getId()); application.setAttribute("activeSessions",activeSessions); } } } }
|