本文整理汇总了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);
}
示例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;
}