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


Java SessionManager.createSession方法代码示例

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


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

示例1: getSession

import io.undertow.server.session.SessionManager; //导入方法依赖的package包/类
public HttpSessionImpl getSession(final ServletContextImpl originalServletContext, final HttpServerExchange exchange, boolean create) {
    SessionConfig c = originalServletContext.getSessionConfig();
    HttpSessionImpl httpSession = exchange.getAttachment(sessionAttachmentKey);
    if (httpSession != null && httpSession.isInvalid()) {
        exchange.removeAttachment(sessionAttachmentKey);
        httpSession = null;
    }
    if (httpSession == null) {
        final SessionManager sessionManager = deployment.getSessionManager();
        Session session = sessionManager.getSession(exchange, c);
        if (session != null) {
            httpSession = SecurityActions.forSession(session, this, false);
            exchange.putAttachment(sessionAttachmentKey, httpSession);
        } else if (create) {

            String existing = c.findSessionId(exchange);
            if (originalServletContext != this) {
                //this is a cross context request
                //we need to make sure there is a top level session
                originalServletContext.getSession(originalServletContext, exchange, true);
            } else if (existing != null) {
                c.clearSession(exchange, existing);
            }

            final Session newSession = sessionManager.createSession(exchange, c);
            httpSession = SecurityActions.forSession(newSession, this, true);
            exchange.putAttachment(sessionAttachmentKey, httpSession);
        }
    }
    return httpSession;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:ServletContextImpl.java

示例2: getOrCreateSession

import io.undertow.server.session.SessionManager; //导入方法依赖的package包/类
/**
 * Gets the active session, creating a new one if one does not exist
 * @param exchange The exchange
 * @return The session
 */
public static Session getOrCreateSession(final HttpServerExchange exchange) {
    SessionManager sessionManager = exchange.getAttachment(SessionManager.ATTACHMENT_KEY);
    SessionConfig sessionConfig = exchange.getAttachment(SessionConfig.ATTACHMENT_KEY);
    if(sessionManager == null) {
        throw UndertowMessages.MESSAGES.sessionManagerNotFound();
    }
    Session session = sessionManager.getSession(exchange, sessionConfig);
    if(session == null) {
        session = sessionManager.createSession(exchange, sessionConfig);
    }
    return session;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:Sessions.java


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