BinCatSession.java示例代码片段:

    1. package com.anbai.sec.server.servlet;
    2. import javax.servlet.ServletContext;
    3. import javax.servlet.http.HttpSession;
    4. import javax.servlet.http.HttpSessionContext;
    5. import java.util.Enumeration;
    6. import java.util.Map;
    7. import java.util.concurrent.ConcurrentHashMap;
    8. /**
    9. * BinCat Session实现
    10. */
    11. public class BinCatSession implements HttpSession {
    12. private final String sessionID;
    13. // Http请求Session对象
    14. private final Map<String, Object> sessionMap = new ConcurrentHashMap<String, Object>();
    15. public BinCatSession(String sessionID) {
    16. this.sessionID = sessionID;
    17. }
    18. // 此处省略HttpSession接口中的大部分方法,仅保留几个示例方法...
    19. public Object getAttribute(String name) {
    20. return this.sessionMap.get(name);
    21. }
    22. public void setAttribute(String name, Object value) {
    23. this.sessionMap.put(name, value);
    24. }
    25. }