⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractsessionmanager.java

📁 是离开的肌肤了卡机是离开的就富利卡及是了的开发及拉考试及的福利科技阿斯利康的肌肤莱卡及时的离开福建阿斯顿发
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        Session s = ((SessionIf)session).getSession();        return s.isValid();    }        /* ------------------------------------------------------------ */    public String getClusterId(HttpSession session)    {        Session s = ((SessionIf)session).getSession();        return s.getClusterId();    }        /* ------------------------------------------------------------ */    public String getNodeId(HttpSession session)    {        Session s = ((SessionIf)session).getSession();        return s.getNodeId();    }    /* ------------------------------------------------------------ */    /**     * Create a new HttpSession for a request     */    public HttpSession newHttpSession(HttpServletRequest request)    {        Session session=newSession(request);        session.setMaxInactiveInterval(_dftMaxIdleSecs);        addSession(session,true);        return session;    }    /* ------------------------------------------------------------ */    public void removeEventListener(EventListener listener)    {        if (listener instanceof HttpSessionAttributeListener)            _sessionAttributeListeners=LazyList.remove(_sessionAttributeListeners,listener);        if (listener instanceof HttpSessionListener)            _sessionListeners=LazyList.remove(_sessionListeners,listener);    }    /* ------------------------------------------------------------ */    public void resetStats()    {        _minSessions=getSessions();        _maxSessions=getSessions();    }    /* ------------------------------------------------------------ */    /**     * @param httpOnly     *            The httpOnly to set.     */    public void setHttpOnly(boolean httpOnly)    {        _httpOnly=httpOnly;    }        /* ------------------------------------------------------------ */    /**     * @param metaManager The metaManager used for cross context session management.     */    public void setIdManager(SessionIdManager metaManager)    {        _sessionIdManager=metaManager;    }    /* ------------------------------------------------------------ */    public void setMaxCookieAge(int maxCookieAgeInSeconds)    {        _maxCookieAge=maxCookieAgeInSeconds;                if (_maxCookieAge>0 && _refreshCookieAge==0)            _refreshCookieAge=_maxCookieAge/3;                }    /* ------------------------------------------------------------ */    /**     * @param seconds     */    public void setMaxInactiveInterval(int seconds)    {        _dftMaxIdleSecs=seconds;    }    /* ------------------------------------------------------------ */    /**     * @deprecated use {@link #setIdManager(SessionIdManager)}     */    public void setMetaManager(SessionIdManager metaManager)    {        setIdManager(metaManager);    }    /* ------------------------------------------------------------ */    public void setRefreshCookieAge(int ageInSeconds)    {        _refreshCookieAge=ageInSeconds;    }    /* ------------------------------------------------------------ */    /**     * @param secureCookies     *            The secureCookies to set.     */    public void setSecureCookies(boolean secureCookies)    {        _secureCookies=secureCookies;    }    public void setSessionCookie(String cookieName)    {        _sessionCookie=cookieName;    }    public void setSessionDomain(String domain)    {        _sessionDomain=domain;    }    /* ------------------------------------------------------------ */    /**     * @param sessionHandler     *            The sessionHandler to set.     */    public void setSessionHandler(SessionHandler sessionHandler)    {        _sessionHandler=sessionHandler;    }    /* ------------------------------------------------------------ */    public void setSessionPath(String path)    {        _sessionPath=path;    }    /* ------------------------------------------------------------ */    /** Set the session ID URL parameter name     * @param param The parameter name for session id URL rewriting (null or "none" for no rewriting).     */    public void setSessionURL(String param)    {        _sessionURL=(param==null||"none".equals(param))?null:param;        _sessionURLPrefix=(param==null||"none".equals(param))?null:(";"+_sessionURL+"=");    }    /* ------------------------------------------------------------ */    /**     * @param usingCookies     *            The usingCookies to set.     */    public void setUsingCookies(boolean usingCookies)    {        _usingCookies=usingCookies;    }    protected abstract void addSession(Session session);    /* ------------------------------------------------------------ */    /**     * Add the session Registers the session with this manager and registers the     * session ID with the sessionIDManager;     */    protected void addSession(Session session, boolean created)    {        synchronized (_sessionIdManager)        {            _sessionIdManager.addSession(session);            synchronized (this)            {                addSession(session);                if (getSessions()>this._maxSessions)                    this._maxSessions=getSessions();            }        }        if (!created)        {            session.didActivate();        }        else if (_sessionListeners!=null)        {            HttpSessionEvent event=new HttpSessionEvent(session);            for (int i=0; i<LazyList.size(_sessionListeners); i++)                ((HttpSessionListener)LazyList.get(_sessionListeners,i)).sessionCreated(event);        }    }        /* ------------------------------------------------------------ */    /**     * Get a known existingsession     * @param idInCluster The session ID in the cluster, stripped of any worker name.     * @return A Session or null if none exists.     */    public abstract Session getSession(String idInCluster);    protected abstract void invalidateSessions();        /* ------------------------------------------------------------ */    /**     * Create a new session instance     * @param request     * @return     */    protected abstract Session newSession(HttpServletRequest request);        /* ------------------------------------------------------------ */    /**     * @return true if the cluster node id (worker id) is returned as part of the session id by {@link HttpSession#getId()}. Default is false.      */    public boolean isNodeIdInSessionId()    {        return _nodeIdInSessionId;    }    /* ------------------------------------------------------------ */    /**     * @param nodeIdInSessionId true if the cluster node id (worker id) will be returned as part of the session id by {@link HttpSession#getId()}. Default is false.     */    public void setNodeIdInSessionId(boolean nodeIdInSessionId)    {        _nodeIdInSessionId=nodeIdInSessionId;    }    /* ------------------------------------------------------------ */    /** Remove session from manager      * @param session The session to remove     * @param invalidate True if {@link HttpSessionListener#sessionDestroyed(HttpSessionEvent)} and     * {@link SessionIdManager#invalidateAll(String)} should be called.     */    public void removeSession(HttpSession session, boolean invalidate)    {        Session s = ((SessionIf)session).getSession();        removeSession(s,invalidate);    }    /* ------------------------------------------------------------ */    /** Remove session from manager      * @param session The session to remove     * @param invalidate True if {@link HttpSessionListener#sessionDestroyed(HttpSessionEvent)} and     * {@link SessionIdManager#invalidateAll(String)} should be called.     */    public void removeSession(Session session, boolean invalidate)    {        // Remove session from context and global maps        synchronized (_sessionIdManager)        {            boolean removed = false;                        synchronized (this)            {                //take this session out of the map of sessions for this context                if (getSession(session.getClusterId()) != null)                {                    removed = true;                    removeSession(session.getClusterId());                }            }                           if (removed)            {                // Remove session from all context and global id maps                _sessionIdManager.removeSession(session);                if (invalidate)                    _sessionIdManager.invalidateAll(session.getClusterId());            }        }                if (invalidate && _sessionListeners!=null)        {            HttpSessionEvent event=new HttpSessionEvent(session);            for (int i=LazyList.size(_sessionListeners); i-->0;)                ((HttpSessionListener)LazyList.get(_sessionListeners,i)).sessionDestroyed(event);        }        if (!invalidate)        {            session.willPassivate();        }    }    /* ------------------------------------------------------------ */    protected abstract void removeSession(String idInCluster);        /* ------------------------------------------------------------ */    /**     * Null returning implementation of HttpSessionContext     *      * @author Greg Wilkins (gregw)     */    public static class NullSessionContext implements HttpSessionContext    {        /* ------------------------------------------------------------ */        private NullSessionContext()        {        }        /* ------------------------------------------------------------ */        /**         * @deprecated From HttpSessionContext         */        public Enumeration getIds()        {            return Collections.enumeration(Collections.EMPTY_LIST);        }        /* ------------------------------------------------------------ */        /**         * @deprecated From HttpSessionContext         */        public HttpSession getSession(String id)        {            return null;        }    }    /* ------------------------------------------------------------ */    /* ------------------------------------------------------------ */    /* ------------------------------------------------------------ */    /**     * Interface that any session wrapper should implement so that     * SessionManager may access the Jetty session implementation.     *     */    public interface SessionIf extends HttpSession    {        public Session getSession();    }        /* ------------------------------------------------------------ */    /* ------------------------------------------------------------ */    /* ------------------------------------------------------------ */    /**     *      * <p>     * Implements {@link javax.servlet.HttpSession} from the {@link javax.servlet} package.        * </p>     * @author gregw     *     */    public abstract class Session implements SessionIf, Serializable    {        protected final String _clusterId;        protected final String _nodeId;        protected boolean _idChanged;        protected final long _created;        protected long _cookieSet;        protected long _accessed;        protected long _lastAccessed;        protected boolean _invalid;        protected boolean _doInvalidate;        protected long _maxIdleMs=_dftMaxIdleSecs*1000;        protected boolean _newSession;        protected Map _values;        protected int _requests;        /* ------------------------------------------------------------- */        protected Session(HttpServletRequest request)        {            _newSession=true;            _created=System.currentTimeMillis();            _clusterId=_sessionIdManager.newSessionId(request,_created);            _nodeId=_sessionIdManager.getNodeId(_clusterId,request);            _accessed=_created;            _requests=1;        }        /* ------------------------------------------------------------- */        protected Session(long created, String clusterId)        {            _created=created;            _clusterId=clusterId;            _nodeId=_sessionIdManager.getNodeId(_clusterId,null);            _accessed=_created;        }        /* ------------------------------------------------------------- */        public Session getSession()        {            return this;        }                /* ------------------------------------------------------------- */        protected void initValues()         {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -