/** * This method is invoked when an attribute is replaced in the ServletContext object * * @param event Description of the Parameter */ public void attributeReplaced(HttpSessionBindingEvent event) { // This event has a handle to the old User object ServletContext context = event.getSession().getServletContext(); // The user has logged in if ("User".equals(event.getName())) { UserBean thisUser = (UserBean) event.getValue(); thisUser.setSessionId(event.getSession().getId()); Tracker tracker = ((SystemStatus) ((Hashtable) context.getAttribute("SystemStatus")) .get(thisUser.getConnectionElement().getUrl())) .getTracker(); tracker.remove(event.getSession().getId()); tracker.add(thisUser.getSessionId(), thisUser); } }
/** * This method is invoked when an attribute is added to the ServletContext object * * @param event Description of the Parameter */ public void attributeAdded(HttpSessionBindingEvent event) { ServletContext context = event.getSession().getServletContext(); if ("User".equals(event.getName())) { // A user session has been created, can be a portal user or system user UserBean thisUser = (UserBean) event.getValue(); thisUser.setSessionId(event.getSession().getId()); // Track website users Hashtable systems = (Hashtable) context.getAttribute("SystemStatus"); if (systems != null && thisUser.getConnectionElement() != null) { SystemStatus systemStatus = (SystemStatus) systems.get(thisUser.getConnectionElement().getUrl()); if (systemStatus != null) { Tracker tracker = ((SystemStatus) ((Hashtable) context.getAttribute("SystemStatus")) .get(thisUser.getConnectionElement().getUrl())) .getTracker(); tracker.add(thisUser.getSessionId(), thisUser); } } } }