public void attributeReplaced(HttpSessionBindingEvent se) { if (se.getName().equals("orderDetailsMap")) { // System.out.println(" replaced map attribute "); // do anything additional apart from updating the map, done // elsewhere // set a flag attribute for billing updating // @SuppressWarnings("unused") // Map<User, List<OrderDetails>> mapOfOrders = (HashMap<User, List<OrderDetails>>) (se // .getSession().getAttribute("orderDetailsMap")); // System.out.println(" replaced map attribute "); } if (se.getName().equals("orderDetailsMap")) { if (!se.getSession().isNew()) { // System.out.println(" replaced map attribute "); @SuppressWarnings("unchecked") Map<User, List<OrderDetails>> mapOfOrders = (HashMap<User, List<OrderDetails>>) (se.getSession().getAttribute("orderDetailsMap")); // OrderDetails orderDetails = new OrderDetails(); // mapOfOrders.put(user,orderDetails); se.getSession().setAttribute("orderDetailsMap", mapOfOrders); // System.out.println(" session attribute replaced, map size " // + mapOfOrders.size()); } } }
/* * (non-Javadoc) * * @see * javax.servlet.http.HttpSessionBindingListener#valueUnbound(javax.servlet * .http.HttpSessionBindingEvent) */ public void valueUnbound(HttpSessionBindingEvent event) { // 刷新页面的时候,TSysUser为null,所以要判断一下 LoginUserVO user = (LoginUserVO) event.getValue(); if (user != null) { /** ********************** UniId begin ******************************** */ // 通知统一身份认证服务中心。此处的实现是通过数据库 boolean singleLogin = PropDbUtil.getBoolean(IdConstants.SINGLE_LOGIN); // 是否开启了同一用户同一时间所有节点上只能登录一个的要求 if (singleLogin) { String sql = SQLConfigUtil.getSql("sql.loginUserVO.delete"); DBUtil.executeSQL(sql, user.getUserloginid()); // 移除在线用户表中用户信息 } /** ********************** UniId end ******************************** */ onlineUsers.remove(event.getSession().getId()); if (LOG.isInfoEnabled()) { LOG.info( user.getUsername() + "[账号:" + user.getUserloginid() + "]" + " 退出系统" + ",目前有" + getCurrentOnlineCount() + "个用户已登录"); } } else { if (LOG.isInfoEnabled()) { LOG.info(" 一个用户刷新系统" + ",目前有" + getCurrentOnlineCount() + "个用户已登录"); } } }
/* * (non-Javadoc) * * @see * javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet * .http.HttpSessionBindingEvent) */ public void valueBound(HttpSessionBindingEvent event) { LoginUserVO user = (LoginUserVO) event.getValue(); onlineUsers.put(event.getSession().getId(), user); if (LOG.isInfoEnabled()) { LOG.info( user.getUsername() + "[账号:" + user.getUserloginid() + "]" + " 登录系统" + ",目前有" + getCurrentOnlineCount() + "个用户已登录"); } /** ********************** UniId begin ******************************** */ // 通知统一身份认证服务中心。此处的实现是通过数据库 boolean singleLogin = PropDbUtil.getBoolean(IdConstants.SINGLE_LOGIN); // 是否开启了同一用户同一时间所有节点上只能登录一个的要求 if (singleLogin) { try { String sql = SQLConfigUtil.getSql("sql.loginUserVO.count"); int onlineNum = DBUtil.count(sql, getUserloginid()); if (onlineNum == 0) { sql = SQLConfigUtil.getSql("sql.loginUserVO.insert"); DBUtil.executeSQL( sql, getUserloginid(), getClientIP(), getServerIP(), DateUtil.currentTime()); } } catch (SQLException e) { LOG.error(e); } } /** ********************** UniId end ******************************** */ }
public void attributeReplaced(HttpSessionBindingEvent evt) { final String name = evt.getName(); if (!shallIgnore(name)) { final Session sess = Sessions.getCurrent(); if (sess instanceof SimpleSession && evt.getSession().equals(sess.getNativeSession())) ((SimpleSession) sess).getScopeListeners().notifyReplaced(name, evt.getValue()); } }
/** * This method is designed to catch when user's login and record their name * * @param event the event to process * @see * javax.servlet.http.HttpSessionAttributeListener#attributeAdded(javax.servlet.http.HttpSessionBindingEvent) */ public void attributeAdded(HttpSessionBindingEvent event) { if (event.getName().equals(EVENT_KEY) && !isAnonymous()) { SecurityContext securityContext = (SecurityContext) event.getValue(); if (securityContext.getAuthentication().getPrincipal() instanceof User) { User user = (User) securityContext.getAuthentication().getPrincipal(); addUsername(user); } } }
@Override public void attributeAdded(HttpSessionBindingEvent _event) { System.out.println( "edu.temple.cis3238.wiki.WikiEventMonitor.[SESSION]attributeAdded()\n added " + _event.getName() + _event.toString()); LOG.info(Objects.toString(_event.getValue().toString())); LOG.info(Objects.toString(_event.getSource())); }
/** * When user's logout, remove their name from the hashMap * * @param event the session binding event * @see * javax.servlet.http.HttpSessionAttributeListener#attributeRemoved(javax.servlet.http.HttpSessionBindingEvent) */ public void attributeRemoved(HttpSessionBindingEvent event) { if (event.getName().equals(EVENT_KEY) && !isAnonymous()) { SecurityContext securityContext = (SecurityContext) event.getValue(); Authentication auth = securityContext.getAuthentication(); if (auth != null && (auth.getPrincipal() instanceof User)) { User user = (User) auth.getPrincipal(); removeUsername(user); } } }
/** {@inheritDoc} */ @Override public void attributeReplaced(HttpSessionBindingEvent event) { if (event.getName().equals(EVENT_KEY) && !isAnonymous()) { Authentication auth = ((SecurityContext) event.getValue()).getAuthentication(); if (auth != null && auth.getPrincipal() instanceof User) { addUser((User) auth.getPrincipal(), event.getSession().getServletContext()); } } }
public void attributeRemoved(HttpSessionBindingEvent event) { // TODO Auto-generated method stub if (event.getName().equals("LOGIN_IP")) { try { OnlineCounter.doUser(event.getValue(), true); } catch (Exception e) { e.printStackTrace(); } } }
@Override public void attributeReplaced(final HttpSessionBindingEvent se) { se.getSession() .getServletContext() .log( "Session Attribute replaced (session id=" + se.getSession().getId() + ") " + se.getName() + "=" + se.getValue()); }
private void checkAttribute( HttpSessionBindingEvent event, String orderAttributeName, String keyItemName, String message) { String currentAttributeName = event.getName(); String currentItemName = (String) event.getValue(); if (currentAttributeName.equals(orderAttributeName) && currentItemName.equals(keyItemName)) { ServletContext context = event.getSession().getServletContext(); context.log("Customer" + message + keyItemName + "."); } }
/** * 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); } }
public void valueUnbound(HttpSessionBindingEvent be) { if (be.getName().equals("Session")) { try { cleanUp(); // remove references in hash right away (this method is synchronized) } catch (ServletException ex) { dbgApp("ServletException: " + ex.getMessage()); } } }
/** * This method is invoked when an attribute is removed from the ServletContext object * * @param se Description of the Parameter */ public void attributeRemoved(HttpSessionBindingEvent se) { ServletContext context = se.getSession().getServletContext(); try { if (se.getName().equals("User")) { UserBean thisUser = (UserBean) se.getValue(); if (thisUser != null) { // Internal SessionManager int userId = thisUser.getActualUserId(); if (userId > -2) { // If context reloaded, then SystemStatus is null, but user is valid Hashtable systems = (Hashtable) context.getAttribute("SystemStatus"); if (systems != null) { SystemStatus systemStatus = (SystemStatus) systems.get(thisUser.getConnectionElement().getUrl()); if (systemStatus != null) { // Remove the user from the session if it already is there SessionManager thisManager = systemStatus.getSessionManager(); if (thisManager != null) { UserSession thisSession = thisManager.getUserSession(userId); if (thisSession != null && thisSession.getId().equals(thisUser.getSessionId())) { if (System.getProperty("DEBUG") != null) { System.out.println( "ContextSessionListener-> Session for user " + userId + " ended"); } thisManager.removeUser(userId); if (System.getProperty("DEBUG") != null) { System.out.println( "ContextSessionListener-> User removed from valid user list"); } } } // Website Tracker Tracker tracker = systemStatus.getTracker(); tracker.remove(thisUser.getSessionId()); } } } } } } catch (Exception e) { e.printStackTrace(System.out); System.out.println("ContextSessionListener-> attributeRemoved Error: " + e.toString()); } }
public void attributeAdded(HttpSessionBindingEvent event) { // TODO Auto-generated method stub if (event.getName().equals("LOGIN_IP")) { try { OnlineCounter.doUser(event.getValue(), false); // List list = OnlineCounter.getOnline(); // 循环list // for (int i = 0; i < list.size(); i++) { // String[] temp = (String[])list.get(i); // System.out.println("用户"+i+":ip:"+temp[0]+"---"+temp[1]); // } // System.out.println("在线用户个数:"+OnlineCounter.getOnlineAllCount()); } catch (Exception e) { e.printStackTrace(); } } }
/** * Seems like it called after our listeners was unbounded from http session. Looks like view scope * it destroyed. But should we call callback or not is a big question. * * @see HttpSessionBindingListener for more details */ @Override public void valueUnbound(HttpSessionBindingEvent event) { // logger.trace("Session event unbound " + event.getName()); final Set<ViewScopeViewMapListener> listeners; synchronized (sessionToListeners) { if (sessionToListeners.containsKey(event.getSession())) { listeners = sessionToListeners.get(event.getSession()); sessionToListeners.remove(event.getSession()); } else { listeners = null; } } if (listeners != null) { // I just hope that JSF context already done this job for (ViewScopeViewMapListener listener : listeners) { // As long as our callbacks can run only once - this is not such big deal listener.doCallback(); } } }
/** * 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); } } } }
public void attributeAdded(HttpSessionBindingEvent se) { HttpSession session = se.getSession(); String attributeName = se.getName(); if (attributeName.equals("orderDetailsMap")) { // System.out.println(" session attribute is " + attributeName); // System.out.println(" session id retrieved says : - " // + session.getId()); // System.out // .println(" session id is New says : - " + session.isNew()); // new user session -- set session id as the User identifier // only for the first time of session User user = new User(se.getSession().getId()); List<OrderDetails> orderDetailsList = new ArrayList<OrderDetails>(); Map<User, List<OrderDetails>> mapOfOrders = new HashMap<User, List<OrderDetails>>(); mapOfOrders.put(user, orderDetailsList); se.getSession().setAttribute("orderDetailsMap", mapOfOrders); // System.out.println(" attribute added, map size " // + mapOfOrders.size()); } }
public void valueUnbound(HttpSessionBindingEvent arg0) { logger.debug("TreeView eliminado de session " + arg0.toString()); }
@Override public void attributeReplaced(HttpSessionBindingEvent event) { log.debug("Session attribute replaced: " + event.getName() + ":" + event.getValue()); }
@Override public void valueUnbound(HttpSessionBindingEvent event) { WebContext.<Map<String, String>>getBean("loginHolderMap").remove(event.getSession().getId()); }
public void valueUnbound(HttpSessionBindingEvent event) { if (event.getName().equals("lyskom") && !suspended) { lyskom.shutdown(); } }
/* * Оставлено для подстраховочной очистки ресурсов (закрытия соединений с БД) */ @Override public void valueUnbound(HttpSessionBindingEvent bindingEvent) { if (JEP_SECURITY_MODULE_ATTRIBUTE_NAME.equals(bindingEvent.getName())) { onExpiredSession(bindingEvent.getSession().getId()); } }
public void attributeRemoved(HttpSessionBindingEvent se) { if (se.getName().equals("orderDetailsMap")) { // System.out.println(" removed map attribute "); } }
public void valueUnbound(HttpSessionBindingEvent evt) { Debug.info("TT Session value unbound ... " + evt.getSession().getId()); }
@Override public void attributeReplaced(HttpSessionBindingEvent event) { event.getSession().getServletContext().removeAttribute(event.getName()); event.getSession().getServletContext().setAttribute(event.getName(), event.getValue()); }
@Override public void attributeReplaced(HttpSessionBindingEvent _event) { String sessionID = _event.getSession().getId(); }
public void valueBound(HttpSessionBindingEvent be) { if (be.getName().equals("Session")) { // actually, we have a constructor already, // so maybe do nothing for the bind event } }