blob: 082fa4ec54e8e34cb1b0bcb6d1b529cae1743d6b [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_92) on Mon Sep 12 21:42:53 EDT 2016 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ThreadContext (Apache Shiro 1.3.2 API)</title>
<meta name="date" content="2016-09-12">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="ThreadContext (Apache Shiro 1.3.2 API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9,"i9":9,"i10":9,"i11":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/ThreadContext.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/shiro/util/StringUtils.html" title="class in org.apache.shiro.util"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../org/apache/shiro/util/ThreadState.html" title="interface in org.apache.shiro.util"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/shiro/util/ThreadContext.html" target="_top">Frames</a></li>
<li><a href="ThreadContext.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.shiro.util</div>
<h2 title="Class ThreadContext" class="title">Class ThreadContext</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>org.apache.shiro.util.ThreadContext</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public abstract class <a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.46">ThreadContext</a>
extends <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre>
<div class="block">A ThreadContext provides a means of binding and unbinding objects to the
current thread based on key/value pairs.
<p/>
<p>An internal <a href="http://java.sun.com/javase/6/docs/api/java/util/HashMap.html?is-external=true" title="class or interface in java.util"><code>HashMap</code></a> is used to maintain the key/value pairs
for each thread.</p>
<p/>
<p>If the desired behavior is to ensure that bound data is not shared across
threads in a pooled or reusable threaded environment, the application (or more likely a framework) must
bind and remove any necessary values at the beginning and end of stack
execution, respectively (i.e. individually explicitly or all via the <tt>clear</tt> method).</p></div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>0.1</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../org/apache/shiro/util/ThreadContext.html#remove--"><code>remove()</code></a></dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#SECURITY_MANAGER_KEY">SECURITY_MANAGER_KEY</a></span></code>&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#SUBJECT_KEY">SUBJECT_KEY</a></span></code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier</th>
<th class="colLast" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>protected </code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#ThreadContext--">ThreadContext</a></span>()</code>
<div class="block">Default no-argument constructor.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#bind-org.apache.shiro.mgt.SecurityManager-">bind</a></span>(<a href="../../../../org/apache/shiro/mgt/SecurityManager.html" title="interface in org.apache.shiro.mgt">SecurityManager</a>&nbsp;securityManager)</code>
<div class="block">Convenience method that simplifies binding the application's SecurityManager instance to the ThreadContext.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#bind-org.apache.shiro.subject.Subject-">bind</a></span>(<a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject">Subject</a>&nbsp;subject)</code>
<div class="block">Convenience method that simplifies binding a Subject to the ThreadContext.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>static <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#get-java.lang.Object-">get</a></span>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;key)</code>
<div class="block">Returns the object for the specified <code>key</code> that is bound to
the current thread.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>static <a href="http://java.sun.com/javase/6/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>,<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#getResources--">getResources</a></span>()</code>
<div class="block">Returns the ThreadLocal Map.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>static <a href="../../../../org/apache/shiro/mgt/SecurityManager.html" title="interface in org.apache.shiro.mgt">SecurityManager</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#getSecurityManager--">getSecurityManager</a></span>()</code>
<div class="block">Convenience method that simplifies retrieval of the application's SecurityManager instance from the current
thread.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>static <a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject">Subject</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#getSubject--">getSubject</a></span>()</code>
<div class="block">Convenience method that simplifies retrieval of a thread-bound Subject.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#put-java.lang.Object-java.lang.Object-">put</a></span>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;key,
<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;value)</code>
<div class="block">Binds <tt>value</tt> for the given <code>key</code> to the current thread.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#remove--">remove</a></span>()</code>
<div class="block"><a href="http://java.sun.com/javase/6/docs/api/java/lang/ThreadLocal.html?is-external=true#remove--" title="class or interface in java.lang"><code>Remove</code></a>s the underlying <a href="http://java.sun.com/javase/6/docs/api/java/lang/ThreadLocal.html?is-external=true" title="class or interface in java.lang"><code>ThreadLocal</code></a> from the thread.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>static <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#remove-java.lang.Object-">remove</a></span>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;key)</code>
<div class="block">Unbinds the value for the given <code>key</code> from the current
thread.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#setResources-java.util.Map-">setResources</a></span>(<a href="http://java.sun.com/javase/6/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>,<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&gt;&nbsp;newResources)</code>
<div class="block">Allows a caller to explicitly set the entire resource map.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>static <a href="../../../../org/apache/shiro/mgt/SecurityManager.html" title="interface in org.apache.shiro.mgt">SecurityManager</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#unbindSecurityManager--">unbindSecurityManager</a></span>()</code>
<div class="block">Convenience method that simplifies removal of the application's SecurityManager instance from the thread.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>static <a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject">Subject</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/shiro/util/ThreadContext.html#unbindSubject--">unbindSubject</a></span>()</code>
<div class="block">Convenience method that simplifies removal of a thread-local Subject from the thread.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="SECURITY_MANAGER_KEY">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>SECURITY_MANAGER_KEY</h4>
<pre>public static final&nbsp;<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.53">SECURITY_MANAGER_KEY</a></pre>
</li>
</ul>
<a name="SUBJECT_KEY">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>SUBJECT_KEY</h4>
<pre>public static final&nbsp;<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.54">SUBJECT_KEY</a></pre>
</li>
</ul>
</li>
</ul>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="ThreadContext--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>ThreadContext</h4>
<pre>protected&nbsp;<a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.61">ThreadContext</a>()</pre>
<div class="block">Default no-argument constructor.</div>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="getResources--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getResources</h4>
<pre>public static&nbsp;<a href="http://java.sun.com/javase/6/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>,<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&gt;&nbsp;<a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.70">getResources</a>()</pre>
<div class="block">Returns the ThreadLocal Map. This Map is used internally to bind objects
to the current thread by storing each object under a unique key.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the map of bound resources</dd>
</dl>
</li>
</ul>
<a name="setResources-java.util.Map-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setResources</h4>
<pre>public static&nbsp;void&nbsp;<a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.86">setResources</a>(<a href="http://java.sun.com/javase/6/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>,<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&gt;&nbsp;newResources)</pre>
<div class="block">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 <a href="../../../../org/apache/shiro/util/ThreadContext.html#getResources--"><code>getResources()</code></a> method, which will give you the existing state.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>newResources</code> - the resources to replace the existing <a href="../../../../org/apache/shiro/util/ThreadContext.html#getResources--"><code>resources</code></a>.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.0</dd>
</dl>
</li>
</ul>
<a name="get-java.lang.Object-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>get</h4>
<pre>public static&nbsp;<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;<a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.123">get</a>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;key)</pre>
<div class="block">Returns the object for the specified <code>key</code> that is bound to
the current thread.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>key</code> - the key that identifies the value to return</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the object keyed by <code>key</code> or <code>null</code> if
no value exists for the specified <code>key</code></dd>
</dl>
</li>
</ul>
<a name="put-java.lang.Object-java.lang.Object-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>put</h4>
<pre>public static&nbsp;void&nbsp;<a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.153">put</a>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;key,
<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;value)</pre>
<div class="block">Binds <tt>value</tt> for the given <code>key</code> to the current thread.
<p/>
<p>A <tt>null</tt> <tt>value</tt> has the same effect as if <tt>remove</tt> was called for the given
<tt>key</tt>, i.e.:
<p/>
<pre>
if ( value == null ) {
remove( key );
}</pre></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>key</code> - The key with which to identify the <code>value</code>.</dd>
<dd><code>value</code> - The value to bind to the thread.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the <code>key</code> argument is <tt>null</tt>.</dd>
</dl>
</li>
</ul>
<a name="remove-java.lang.Object-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>remove</h4>
<pre>public static&nbsp;<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;<a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.181">remove</a>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;key)</pre>
<div class="block">Unbinds the value for the given <code>key</code> from the current
thread.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>key</code> - The key identifying the value bound to the current thread.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the object unbound or <tt>null</tt> if there was nothing bound
under the specified <tt>key</tt> name.</dd>
</dl>
</li>
</ul>
<a name="remove--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>remove</h4>
<pre>public static&nbsp;void&nbsp;<a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.202">remove</a>()</pre>
<div class="block"><a href="http://java.sun.com/javase/6/docs/api/java/lang/ThreadLocal.html?is-external=true#remove--" title="class or interface in java.lang"><code>Remove</code></a>s the underlying <a href="http://java.sun.com/javase/6/docs/api/java/lang/ThreadLocal.html?is-external=true" title="class or interface in java.lang"><code>ThreadLocal</code></a> from the thread.
<p/>
This method is meant to be the final 'clean up' operation that is called at the end of thread execution to
prevent thread corruption in pooled thread environments.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.0</dd>
</dl>
</li>
</ul>
<a name="getSecurityManager--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getSecurityManager</h4>
<pre>public static&nbsp;<a href="../../../../org/apache/shiro/mgt/SecurityManager.html" title="interface in org.apache.shiro.mgt">SecurityManager</a>&nbsp;<a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.221">getSecurityManager</a>()</pre>
<div class="block">Convenience method that simplifies retrieval of the application's SecurityManager instance from the current
thread. If there is no SecurityManager bound to the thread (probably because framework code did not bind it
to the thread), this method returns <tt>null</tt>.
<p/>
It is merely a convenient wrapper for the following:
<p/>
<code>return (SecurityManager)get( SECURITY_MANAGER_KEY );</code>
<p/>
This method only returns the bound value if it exists - it does not remove it
from the thread. To remove it, one must call <a href="../../../../org/apache/shiro/util/ThreadContext.html#unbindSecurityManager--"><code>unbindSecurityManager()</code></a> instead.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the Subject object bound to the thread, or <tt>null</tt> if there isn't one bound.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>0.9</dd>
</dl>
</li>
</ul>
<a name="bind-org.apache.shiro.mgt.SecurityManager-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bind</h4>
<pre>public static&nbsp;void&nbsp;<a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.242">bind</a>(<a href="../../../../org/apache/shiro/mgt/SecurityManager.html" title="interface in org.apache.shiro.mgt">SecurityManager</a>&nbsp;securityManager)</pre>
<div class="block">Convenience method that simplifies binding the application's SecurityManager instance to the ThreadContext.
<p/>
<p>The method's existence is to help reduce casting in code and to simplify remembering of
ThreadContext key names. The implementation is simple in that, if the SecurityManager is not <tt>null</tt>,
it binds it to the thread, i.e.:
<p/>
<pre>
if (securityManager != null) {
put( SECURITY_MANAGER_KEY, securityManager);
}</pre></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>securityManager</code> - the application's SecurityManager instance to bind to the thread. If the argument is
null, nothing will be done.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>0.9</dd>
</dl>
</li>
</ul>
<a name="unbindSecurityManager--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>unbindSecurityManager</h4>
<pre>public static&nbsp;<a href="../../../../org/apache/shiro/mgt/SecurityManager.html" title="interface in org.apache.shiro.mgt">SecurityManager</a>&nbsp;<a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.263">unbindSecurityManager</a>()</pre>
<div class="block">Convenience method that simplifies removal of the application's SecurityManager instance from the thread.
<p/>
The implementation just helps reduce casting and remembering of the ThreadContext key name, i.e it is
merely a conveient wrapper for the following:
<p/>
<code>return (SecurityManager)remove( SECURITY_MANAGER_KEY );</code>
<p/>
If you wish to just retrieve the object from the thread without removing it (so it can be retrieved later
during thread execution), use the <a href="../../../../org/apache/shiro/util/ThreadContext.html#getSecurityManager--"><code>getSecurityManager()</code></a> method instead.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the application's SecurityManager instance previously bound to the thread, or <tt>null</tt> if there
was none bound.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>0.9</dd>
</dl>
</li>
</ul>
<a name="getSubject--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getSubject</h4>
<pre>public static&nbsp;<a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject">Subject</a>&nbsp;<a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.280">getSubject</a>()</pre>
<div class="block">Convenience method that simplifies retrieval of a thread-bound Subject. If there is no
Subject bound to the thread, this method returns <tt>null</tt>. It is merely a convenient wrapper
for the following:
<p/>
<code>return (Subject)get( SUBJECT_KEY );</code>
<p/>
This method only returns the bound value if it exists - it does not remove it
from the thread. To remove it, one must call <a href="../../../../org/apache/shiro/util/ThreadContext.html#unbindSubject--"><code>unbindSubject()</code></a> instead.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the Subject object bound to the thread, or <tt>null</tt> if there isn't one bound.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>0.2</dd>
</dl>
</li>
</ul>
<a name="bind-org.apache.shiro.subject.Subject-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bind</h4>
<pre>public static&nbsp;void&nbsp;<a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.300">bind</a>(<a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject">Subject</a>&nbsp;subject)</pre>
<div class="block">Convenience method that simplifies binding a Subject to the ThreadContext.
<p/>
<p>The method's existence is to help reduce casting in your own code and to simplify remembering of
ThreadContext key names. The implementation is simple in that, if the Subject is not <tt>null</tt>,
it binds it to the thread, i.e.:
<p/>
<pre>
if (subject != null) {
put( SUBJECT_KEY, subject );
}</pre></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>subject</code> - the Subject object to bind to the thread. If the argument is null, nothing will be done.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>0.2</dd>
</dl>
</li>
</ul>
<a name="unbindSubject--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>unbindSubject</h4>
<pre>public static&nbsp;<a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject">Subject</a>&nbsp;<a href="../../../../src-html/org/apache/shiro/util/ThreadContext.html#line.320">unbindSubject</a>()</pre>
<div class="block">Convenience method that simplifies removal of a thread-local Subject from the thread.
<p/>
The implementation just helps reduce casting and remembering of the ThreadContext key name, i.e it is
merely a conveient wrapper for the following:
<p/>
<code>return (Subject)remove( SUBJECT_KEY );</code>
<p/>
If you wish to just retrieve the object from the thread without removing it (so it can be retrieved later during
thread execution), you should use the <a href="../../../../org/apache/shiro/util/ThreadContext.html#getSubject--"><code>getSubject()</code></a> method for that purpose.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the Subject object previously bound to the thread, or <tt>null</tt> if there was none bound.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>0.2</dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/ThreadContext.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/shiro/util/StringUtils.html" title="class in org.apache.shiro.util"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../org/apache/shiro/util/ThreadState.html" title="interface in org.apache.shiro.util"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/shiro/util/ThreadContext.html" target="_top">Frames</a></li>
<li><a href="ThreadContext.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2004-2016 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.</small></p>
</body>
</html>