|
|
|
@ -1,17 +1,17 @@
|
|
|
|
|
package com.cn.listener;
|
|
|
|
|
package com.cn.listener; // 定义监听器包名
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpSessionActivationListener;
|
|
|
|
|
import javax.servlet.http.HttpSessionAttributeListener;
|
|
|
|
|
import javax.servlet.http.HttpSessionBindingEvent;
|
|
|
|
|
import javax.servlet.http.HttpSessionBindingListener;
|
|
|
|
|
import javax.servlet.http.HttpSessionEvent;
|
|
|
|
|
import javax.servlet.http.HttpSessionListener;
|
|
|
|
|
import javax.servlet.http.HttpSessionActivationListener; // 导入HttpSessionActivationListener接口
|
|
|
|
|
import javax.servlet.http.HttpSessionAttributeListener; // 导入HttpSessionAttributeListener接口
|
|
|
|
|
import javax.servlet.http.HttpSessionBindingEvent; // 导入HttpSessionBindingEvent类
|
|
|
|
|
import javax.servlet.http.HttpSessionBindingListener; // 导入HttpSessionBindingListener接口
|
|
|
|
|
import javax.servlet.http.HttpSessionEvent; // 导入HttpSessionEvent类
|
|
|
|
|
import javax.servlet.http.HttpSessionListener; // 导入HttpSessionListener接口
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* 会员监听器,用于监听会员相关的会话事件。
|
|
|
|
|
* @ClassName: MemberSessionListener
|
|
|
|
|
* @Description: 会员监听器
|
|
|
|
|
* @author: ljy
|
|
|
|
@ -19,76 +19,85 @@ import javax.servlet.http.HttpSessionListener;
|
|
|
|
|
*/
|
|
|
|
|
public class MemberSessionListener implements HttpSessionListener, HttpSessionAttributeListener, HttpSessionActivationListener, HttpSessionBindingListener {
|
|
|
|
|
|
|
|
|
|
private static Map<String, Object> member = new HashMap<String, Object>();//保存当前登录的用户对象
|
|
|
|
|
// 保存当前登录的用户对象
|
|
|
|
|
private static Map<String, Object> member = new HashMap<String, Object>();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Default constructor.
|
|
|
|
|
* 默认构造函数。
|
|
|
|
|
*/
|
|
|
|
|
public MemberSessionListener() {
|
|
|
|
|
// TODO Auto-generated constructor stub
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 当会话被创建时调用的方法。
|
|
|
|
|
* @see HttpSessionListener#sessionCreated(HttpSessionEvent)
|
|
|
|
|
*/
|
|
|
|
|
public void sessionCreated(HttpSessionEvent se) {
|
|
|
|
|
|
|
|
|
|
public void sessionCreated(HttpSessionEvent se) {
|
|
|
|
|
// 当会话被创建时可以执行的操作
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 当会话绑定对象时调用的方法。
|
|
|
|
|
* @see HttpSessionBindingListener#valueBound(HttpSessionBindingEvent)
|
|
|
|
|
*/
|
|
|
|
|
public void valueBound(HttpSessionBindingEvent event) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
public void valueBound(HttpSessionBindingEvent event) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 当会话被销毁时调用的方法。
|
|
|
|
|
* @see HttpSessionListener#sessionDestroyed(HttpSessionEvent)
|
|
|
|
|
*/
|
|
|
|
|
public void sessionDestroyed(HttpSessionEvent se) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
public void sessionDestroyed(HttpSessionEvent se) {
|
|
|
|
|
// 当会话被销毁时可以执行的操作
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 当会话被激活时调用的方法。
|
|
|
|
|
* @see HttpSessionActivationListener#sessionDidActivate(HttpSessionEvent)
|
|
|
|
|
*/
|
|
|
|
|
public void sessionDidActivate(HttpSessionEvent se) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
public void sessionDidActivate(HttpSessionEvent se) {
|
|
|
|
|
// 当会话被激活时可以执行的操作
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 当会话属性被添加时调用的方法。
|
|
|
|
|
* @see HttpSessionAttributeListener#attributeAdded(HttpSessionBindingEvent)
|
|
|
|
|
*/
|
|
|
|
|
public void attributeAdded(HttpSessionBindingEvent se) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
public void attributeAdded(HttpSessionBindingEvent se) {
|
|
|
|
|
// 当会话属性被添加时可以执行的操作
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 当会话属性被移除时调用的方法。
|
|
|
|
|
* @see HttpSessionAttributeListener#attributeRemoved(HttpSessionBindingEvent)
|
|
|
|
|
*/
|
|
|
|
|
public void attributeRemoved(HttpSessionBindingEvent se) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
public void attributeRemoved(HttpSessionBindingEvent se) {
|
|
|
|
|
// 当会话属性被移除时可以执行的操作
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 当会话属性被替换时调用的方法。
|
|
|
|
|
* @see HttpSessionAttributeListener#attributeReplaced(HttpSessionBindingEvent)
|
|
|
|
|
*/
|
|
|
|
|
public void attributeReplaced(HttpSessionBindingEvent se) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
public void attributeReplaced(HttpSessionBindingEvent se) {
|
|
|
|
|
// 当会话属性被替换时可以执行的操作
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 当会话将要被钝化时调用的方法。
|
|
|
|
|
* @see HttpSessionActivationListener#sessionWillPassivate(HttpSessionEvent)
|
|
|
|
|
*/
|
|
|
|
|
public void sessionWillPassivate(HttpSessionEvent se) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
public void sessionWillPassivate(HttpSessionEvent se) {
|
|
|
|
|
// 当会话将要被钝化时可以执行的操作
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 当会话解绑对象时调用的方法。
|
|
|
|
|
* @see HttpSessionBindingListener#valueUnbound(HttpSessionBindingEvent)
|
|
|
|
|
*/
|
|
|
|
|
public void valueUnbound(HttpSessionBindingEvent event) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
public void valueUnbound(HttpSessionBindingEvent event) {
|
|
|
|
|
// 当会话解绑对象时可以执行的操作
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|