package com.slcf.filter;
|
|
import java.util.HashMap;
|
|
import javax.servlet.http.HttpSession;
|
|
public class MySessionContext {
|
private static MySessionContext instance;
|
private HashMap<Object, Object> mymap;
|
|
private MySessionContext() {
|
mymap=new HashMap();
|
}
|
|
public static MySessionContext getInstance(){
|
if(instance == null){
|
instance = new MySessionContext();
|
}
|
return instance;
|
}
|
|
public synchronized void AddSession(HttpSession session){
|
if(session != null){
|
mymap.put(session.getId(), session);
|
}
|
}
|
|
public synchronized void DelSession(HttpSession session){
|
if(session != null){
|
mymap.remove(session.getId());
|
}
|
}
|
|
public synchronized HttpSession getSession(String sessionId){
|
if(sessionId == null){
|
return null;
|
}
|
return (HttpSession) mymap.get(sessionId);
|
}
|
}
|