本文整理汇总了Java中org.mortbay.jetty.servlet.AbstractSessionManager类的典型用法代码示例。如果您正苦于以下问题:Java AbstractSessionManager类的具体用法?Java AbstractSessionManager怎么用?Java AbstractSessionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractSessionManager类属于org.mortbay.jetty.servlet包,在下文中一共展示了AbstractSessionManager类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invalidateAll
import org.mortbay.jetty.servlet.AbstractSessionManager; //导入依赖的package包/类
public void invalidateAll(String id)
{
//take the id out of the list of known sessionids for this node
removeSession(id);
synchronized (_sessionIds)
{
//tell all contexts that may have a session object with this id to
//get rid of them
Handler[] contexts = _server.getChildHandlersByClass(WebAppContext.class);
for (int i=0; contexts!=null && i<contexts.length; i++)
{
AbstractSessionManager manager = ((AbstractSessionManager)((WebAppContext)contexts[i]).getSessionHandler().getSessionManager());
if (manager instanceof GigaSessionManager)
{
((GigaSessionManager)manager).invalidateSession(id);
}
}
}
}
示例2: 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);
}
示例3: invalidateAll
import org.mortbay.jetty.servlet.AbstractSessionManager; //导入依赖的package包/类
/**
* When told to invalidate all session instances that share the same id, we must
* tell all contexts on the server for which it is defined to delete any session
* object they might have matching the id.
*/
public void invalidateAll(String clusterId)
{
Handler[] contexts = _server.getChildHandlersByClass(WebAppContext.class);
for (int i = 0; contexts != null && i < contexts.length; i++)
{
WebAppContext webAppContext = (WebAppContext)contexts[i];
SessionManager sessionManager = webAppContext.getSessionHandler().getSessionManager();
if (sessionManager instanceof AbstractSessionManager)
{
Session session = ((AbstractSessionManager)sessionManager).getSession(clusterId);
if (session != null) session.invalidate();
}
}
}
示例4: initializeWebServer
import org.mortbay.jetty.servlet.AbstractSessionManager; //导入依赖的package包/类
private void initializeWebServer(String name, String hostName,
Configuration conf, String[] pathSpecs)
throws IOException {
Preconditions.checkNotNull(webAppContext);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 250).
QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
: new QueuedThreadPool(maxThreads);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager)sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLog requestLog = HttpRequestLog.getRequestLog(name);
if (requestLog != null) {
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {contexts, requestLogHandler});
webServer.setHandler(handlers);
} else {
webServer.setHandler(contexts);
}
final String appDir = getWebAppsPath(name);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir, conf);
addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
conf = new Configuration(conf);
conf.set(BIND_ADDRESS, hostName);
for (FilterInitializer c : initializers) {
c.initFilter(this, conf);
}
}
addDefaultServlets();
if (pathSpecs != null) {
for (String path : pathSpecs) {
LOG.info("adding path spec: " + path);
addFilterPathMapping(path, webAppContext);
}
}
}
示例5: 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;
}
示例6: initializeWebServer
import org.mortbay.jetty.servlet.AbstractSessionManager; //导入依赖的package包/类
private void initializeWebServer(String name, String hostName,
Configuration conf, String[] pathSpecs)
throws FileNotFoundException, IOException {
Preconditions.checkNotNull(webAppContext);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 250).
QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
: new QueuedThreadPool(maxThreads);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager)sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLog requestLog = HttpRequestLog.getRequestLog(name);
if (requestLog != null) {
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {contexts, requestLogHandler});
webServer.setHandler(handlers);
} else {
webServer.setHandler(contexts);
}
final String appDir = getWebAppsPath(name);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir, conf);
addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
conf = new Configuration(conf);
conf.set(BIND_ADDRESS, hostName);
for (FilterInitializer c : initializers) {
c.initFilter(this, conf);
}
}
addDefaultServlets();
if (pathSpecs != null) {
for (String path : pathSpecs) {
LOG.info("adding path spec: " + path);
addFilterPathMapping(path, webAppContext);
}
}
}
示例7: initializeWebServer
import org.mortbay.jetty.servlet.AbstractSessionManager; //导入依赖的package包/类
private void initializeWebServer(String name, String hostName,
Configuration conf, String[] pathSpecs)
throws IOException {
Preconditions.checkNotNull(webAppContext);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 250).
QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
: new QueuedThreadPool(maxThreads);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager)sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLog requestLog = HttpRequestLog.getRequestLog(name);
if (requestLog != null) {
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {contexts, requestLogHandler});
webServer.setHandler(handlers);
} else {
webServer.setHandler(contexts);
}
final String appDir = getWebAppsPath(name);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir, conf);
Map<String, String> xFrameParams = new HashMap<>();
xFrameParams.put(X_FRAME_ENABLED,
String.valueOf(this.xFrameOptionIsEnabled));
xFrameParams.put(X_FRAME_VALUE, this.xFrameOption.toString());
addGlobalFilter("safety", QuotingInputFilter.class.getName(), xFrameParams);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
conf = new Configuration(conf);
conf.set(BIND_ADDRESS, hostName);
for (FilterInitializer c : initializers) {
c.initFilter(this, conf);
}
}
addDefaultServlets();
if (pathSpecs != null) {
for (String path : pathSpecs) {
LOG.info("adding path spec: " + path);
addFilterPathMapping(path, webAppContext);
}
}
}
示例8: initializeWebServer
import org.mortbay.jetty.servlet.AbstractSessionManager; //导入依赖的package包/类
private void initializeWebServer(String name, String hostName,
Configuration conf, String[] pathSpecs)
throws FileNotFoundException, IOException {
Preconditions.checkNotNull(webAppContext);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 250).
QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
: new QueuedThreadPool(maxThreads);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager)sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLog requestLog = HttpRequestLog.getRequestLog(name);
if (requestLog != null) {
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { requestLogHandler, contexts });
webServer.setHandler(handlers);
} else {
webServer.setHandler(contexts);
}
final String appDir = getWebAppsPath(name);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir, conf);
addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
conf = new Configuration(conf);
conf.set(BIND_ADDRESS, hostName);
for (FilterInitializer c : initializers) {
c.initFilter(this, conf);
}
}
addDefaultServlets();
if (pathSpecs != null) {
for (String path : pathSpecs) {
LOG.info("adding path spec: " + path);
addFilterPathMapping(path, webAppContext);
}
}
}