当前位置: 首页>>代码示例>>Java>>正文


Java AbstractSessionManager.Session方法代码示例

本文整理汇总了Java中org.mortbay.jetty.servlet.AbstractSessionManager.Session方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractSessionManager.Session方法的具体用法?Java AbstractSessionManager.Session怎么用?Java AbstractSessionManager.Session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mortbay.jetty.servlet.AbstractSessionManager的用法示例。


在下文中一共展示了AbstractSessionManager.Session方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addSession

import org.mortbay.jetty.servlet.AbstractSessionManager; //导入方法依赖的package包/类
@Override
protected void addSession(AbstractSessionManager.Session session, boolean created)
{
    /**
     * SESSION LOCKING
     * This is an entry point for session locking.
     * We enter here when a new session is requested via request.getSession(true).
     */
    if (created) enter(((Session)session).getClusterId());
    super.addSession(session, created);
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:12,代码来源:TerracottaSessionManager.java

示例2: getSession

import org.mortbay.jetty.servlet.AbstractSessionManager; //导入方法依赖的package包/类
public AbstractSessionManager.Session getSession(String clusterId)
{
    Session result = null;

    /**
     * SESSION LOCKING
     * This is an entry point for session locking.
     * We lookup the session given the id, and if it exist we hold the lock.
     * We unlock on end of method, since this method can be called outside
     * an {@link #enter(String)}/{@link #exit(String)} pair.
     */
    enter(clusterId);
    try
    {
        // Need to synchronize because we use a get-then-put that must be atomic
        // on the local session cache
        synchronized (_sessions)
        {
            result = _sessions.get(clusterId);
            if (result == null)
            {
                Log.debug("Session with id {} --> local cache miss", clusterId);

                // Lookup the distributed shared sessionData object.
                // This will migrate the session data to this node from the Terracotta server
                // We have not grabbed the distributed lock associated with this session yet,
                // so another node can migrate the session data as well. This is no problem,
                // since just after this method returns the distributed lock will be grabbed by
                // one node, the session data will be changed and the lock released.
                // The second node contending for the distributed lock will then acquire it,
                // and the session data information will be migrated lazily by Terracotta means.
                // We are only interested in having a SessionData reference locally.
                Log.debug("Distributed session data with id {} --> lookup", clusterId);
                SessionData sessionData = _sessionDatas.get(clusterId);
                if (sessionData == null)
                {
                    Log.debug("Distributed session data with id {} --> not found", clusterId);
                }
                else
                {
                    Log.debug("Distributed session data with id {} --> found", clusterId);
                    // Wrap the migrated session data and cache the Session object
                    result = new Session(sessionData);
                    _sessions.put(clusterId, result);
                }
            }
            else
            {
                Log.debug("Session with id {} --> local cache hit", clusterId);
                if (!_sessionExpirations.containsKey(clusterId))
                {
                    // A session is present in the local cache, but it has been expired
                    // or invalidated on another node, perform local clean up.
                    _sessions.remove(clusterId);
                    result = null;
                    Log.debug("Session with id {} --> local cache stale");
                }
            }
        }
    }
    finally
    {
        /**
         * SESSION LOCKING
         */
        exit(clusterId);
    }
    return result;
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:70,代码来源:TerracottaSessionManager.java


注:本文中的org.mortbay.jetty.servlet.AbstractSessionManager.Session方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。