1 43 package net.jforum; 44 45 import javax.servlet.http.HttpSession ; 46 import javax.servlet.http.HttpSessionEvent ; 47 import javax.servlet.http.HttpSessionListener ; 48 49 import net.jforum.entities.UserSession; 50 import net.jforum.repository.SecurityRepository; 51 52 import org.apache.log4j.Logger; 53 54 58 public class ForumSessionListener implements HttpSessionListener 59 { 60 private static final Logger logger = Logger.getLogger(ForumSessionListener.class); 61 62 65 public void sessionCreated(HttpSessionEvent event) {} 66 67 70 public void sessionDestroyed(HttpSessionEvent event) 71 { 72 HttpSession session = event.getSession(); 73 74 if (session == null) { 75 return; 76 } 77 78 String sessionId = session.getId(); 79 80 try { 81 SessionFacade.storeSessionData(sessionId); 82 } 83 catch (Exception e) { 84 logger.warn(e); 85 } 86 87 UserSession us = SessionFacade.getUserSession(sessionId); 88 89 if (us != null) { 90 SecurityRepository.remove(us.getUserId()); 91 } 92 93 SessionFacade.remove(sessionId); 94 } 95 } 96 | Popular Tags |