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


Java ServletRequestContext.current方法代码示例

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


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

示例1: forSession

import io.undertow.servlet.handlers.ServletRequestContext; //导入方法依赖的package包/类
public static HttpSessionImpl forSession(final Session session, final ServletContext servletContext, final boolean newSession) {
    // forSession is called by privileged actions only so no need to do it again
    ServletRequestContext current = ServletRequestContext.current();
    if (current == null) {
        return new HttpSessionImpl(session, servletContext, newSession, null);
    } else {
        HttpSessionImpl httpSession = current.getSession();
        if (httpSession == null) {
            httpSession = new HttpSessionImpl(session, servletContext, newSession, current);
            current.setSession(httpSession);
        } else {
            if(httpSession.session != session) {
                //in some rare cases it may be that there are two different service contexts involved in the one request
                //in this case we just return a new session rather than using the thread local version
                httpSession = new HttpSessionImpl(session, servletContext, newSession, current);
            }
        }
        return httpSession;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:HttpSessionImpl.java

示例2: currentServletRequestContext

import io.undertow.servlet.handlers.ServletRequestContext; //导入方法依赖的package包/类
static ServletRequestContext currentServletRequestContext() {
    if (System.getSecurityManager() == null) {
        return ServletRequestContext.current();
    } else {
        return AccessController.doPrivileged(new PrivilegedAction<ServletRequestContext>() {
            @Override
            public ServletRequestContext run() {
                return ServletRequestContext.current();
            }
        });
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:SecurityActions.java

示例3: getCurrentSessionId

import io.undertow.servlet.handlers.ServletRequestContext; //导入方法依赖的package包/类
private String getCurrentSessionId(HttpServerExchange exchange) {
	if (exchange == null && ServletRequestContext.current() != null) {
		exchange = ServletRequestContext.current().getExchange();
	}
	if (exchange == null) return null;
	Cookie sessionCookie = exchange.getRequestCookies().get("JSESSIONID");
	if (sessionCookie == null) return null;
	return sessionCookie.getValue();
}
 
开发者ID:openanalytics,项目名称:shinyproxy,代码行数:10,代码来源:DockerService.java


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