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

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

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

ThreadContext.setResources介绍

[英]Allows a caller to explicitly set the entire resource map. This operation overwrites everything that existed previously in the ThreadContext - if you need to retain what was on the thread prior to calling this method, call the #getResources() method, which will give you the existing state.
[中]允许调用方显式设置整个资源映射。此操作将覆盖以前在ThreadContext中存在的所有内容——如果在调用此方法之前需要保留线程上的内容,请调用#getResources()方法,该方法将为您提供现有状态。

代码示例

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

/**
 * {@link ThreadContext#remove Remove}s all thread-state that was bound by this instance.  If any previous
 * thread-bound resources existed prior to the {@link #bind bind} call, they are restored back to the
 * {@code ThreadContext} to ensure the thread state is exactly as it was before binding.
 */
public void restore() {
  ThreadContext.remove();
  if (!CollectionUtils.isEmpty(this.originalResources)) {
    ThreadContext.setResources(this.originalResources);
  }
}

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

/**
 * {@link ThreadContext#remove Remove}s all thread-state that was bound by this instance.  If any previous
 * thread-bound resources existed prior to the {@link #bind bind} call, they are restored back to the
 * {@code ThreadContext} to ensure the thread state is exactly as it was before binding.
 */
public void restore() {
  ThreadContext.remove();
  if (!CollectionUtils.isEmpty(this.originalResources)) {
    ThreadContext.setResources(this.originalResources);
  }
}

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

/**
 * {@link ThreadContext#remove Remove}s all thread-state that was bound by this instance.  If any previous
 * thread-bound resources existed prior to the {@link #bind bind} call, they are restored back to the
 * {@code ThreadContext} to ensure the thread state is exactly as it was before binding.
 */
public void restore() {
  ThreadContext.remove();
  if (!CollectionUtils.isEmpty(this.originalResources)) {
    ThreadContext.setResources(this.originalResources);
  }
}

相关文章