Package org.jrest4guice.rest.commons.sna

Examples of org.jrest4guice.rest.commons.sna.SNASession


    // 从当前会话中获取snaId
    String snaId = (String) session
        .getAttribute(SNAIdRequestServlet.SNA_ID);

    // 从缓存服务器获取当前的会话对象
    SNASession snaSession = this.helper.getSNASession(snaId, session);
    session.setAttribute(CookieUtil.SESSION_NAME, snaId);

    try {
      HttpServletRequest requestWrapper = this.helper
          .createRequestWrapper(hRequest);
      // 设置上下文中的环境变量
      RestContextManager.setContext(requestWrapper, hResponse, params);
      SNASessionProvider.setCurrentSNASession(snaSession);

      // 检测用户当前的安全状态
      if (requestWrapper.getUserPrincipal() != null) {
        SecurityContext securityContext = GuiceContext.getInstance()
            .getBean(SecurityContext.class);
        GuiceContext.getInstance().injectorMembers(securityContext);
        securityContext.getUserPrincipal();
      }

      // 处理当前请求
      new JRest4GuiceProcessor().setUrlPrefix(this.urlPrefix).process(
          requestWrapper, hResponse);
    } catch (Throwable e) {
      error = e;
    } finally {
      // 从缓存服务器客户删除已空的会话对象
      if (snaSession.isEmpty() && snaSession.isDuty()) {
        this.cacheProvider.delete(snaId);
      } else if (snaSession.isDuty()) {
        // 将变更后的会话对象缓存回缓存服务器
        snaSession.setDuty(false);
        this.cacheProvider.put(snaId, snaSession);
      }
      // 清除上下文中的环境变量
      RestContextManager.clearContext();
      SNASessionProvider.clearCurrentSNASession();
View Full Code Here

TOP

Related Classes of org.jrest4guice.rest.commons.sna.SNASession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.