org.apache.shiro.util.ThreadContext.getResources()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中org.apache.shiro.util.ThreadContext.getResources()方法的一些代码示例,展示了ThreadContext.getResources()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadContext.getResources()方法的具体详情如下:
包路径:org.apache.shiro.util.ThreadContext
类名称:ThreadContext
方法名:getResources

ThreadContext.getResources介绍

[英]Returns the ThreadLocal Map. This Map is used internally to bind objects to the current thread by storing each object under a unique key.
[中]返回线程本地映射。通过将每个对象存储在唯一的键下,该映射在内部用于将对象绑定到当前线程。

代码示例

代码示例来源:origin: apache/shiro

/**
 * Binds a {@link Subject} and {@link org.apache.shiro.mgt.SecurityManager SecurityManager} to the
 * {@link ThreadContext} so they can be retrieved later by any
 * {@code SecurityUtils.}{@link org.apache.shiro.SecurityUtils#getSubject() getSubject()} calls that might occur
 * during the thread's execution.
 * <p/>
 * Prior to binding, the {@code ThreadContext}'s existing {@link ThreadContext#getResources() resources} are
 * retained so they can be restored later via the {@link #restore restore} call.
 */
public void bind() {
  SecurityManager securityManager = this.securityManager;
  if ( securityManager == null ) {
    //try just in case the constructor didn't find one at the time:
    securityManager = ThreadContext.getSecurityManager();
  }
  this.originalResources = ThreadContext.getResources();
  ThreadContext.remove();
  ThreadContext.bind(this.subject);
  if (securityManager != null) {
    ThreadContext.bind(securityManager);
  }
}

代码示例来源:origin: org.apache.shiro/shiro-core

/**
 * Binds a {@link Subject} and {@link org.apache.shiro.mgt.SecurityManager SecurityManager} to the
 * {@link ThreadContext} so they can be retrieved later by any
 * {@code SecurityUtils.}{@link org.apache.shiro.SecurityUtils#getSubject() getSubject()} calls that might occur
 * during the thread's execution.
 * <p/>
 * Prior to binding, the {@code ThreadContext}'s existing {@link ThreadContext#getResources() resources} are
 * retained so they can be restored later via the {@link #restore restore} call.
 */
public void bind() {
  SecurityManager securityManager = this.securityManager;
  if ( securityManager == null ) {
    //try just in case the constructor didn't find one at the time:
    securityManager = ThreadContext.getSecurityManager();
  }
  this.originalResources = ThreadContext.getResources();
  ThreadContext.remove();
  ThreadContext.bind(this.subject);
  if (securityManager != null) {
    ThreadContext.bind(securityManager);
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

/**
 * Binds a {@link Subject} and {@link org.apache.shiro.mgt.SecurityManager SecurityManager} to the
 * {@link ThreadContext} so they can be retrieved later by any
 * {@code SecurityUtils.}{@link org.apache.shiro.SecurityUtils#getSubject() getSubject()} calls that might occur
 * during the thread's execution.
 * <p/>
 * Prior to binding, the {@code ThreadContext}'s existing {@link ThreadContext#getResources() resources} are
 * retained so they can be restored later via the {@link #restore restore} call.
 */
public void bind() {
  SecurityManager securityManager = this.securityManager;
  if ( securityManager == null ) {
    //try just in case the constructor didn't find one at the time:
    securityManager = ThreadContext.getSecurityManager();
  }
  this.originalResources = ThreadContext.getResources();
  ThreadContext.remove();
  ThreadContext.bind(this.subject);
  if (securityManager != null) {
    ThreadContext.bind(securityManager);
  }
}

相关文章