blob: 6aa48de5a8901aad0341136877aebdb48e0fd7e8 [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>
<title>ContextServiceDefinition</title>
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../script.js"></script>
<link rel="shortcut icon" href="/img/jakarta-favicon.ico">
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="ContextServiceDefinition";
}
}
catch(err) {
}
//-->
</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="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="../../../jakarta/enterprise/concurrent/ContextService.html" title="interface in jakarta.enterprise.concurrent"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.List.html" title="annotation in jakarta.enterprise.concurrent"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?jakarta/enterprise/concurrent/ContextServiceDefinition.html" target="_top">Frames</a></li>
<li><a href="ContextServiceDefinition.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><a href="#annotation.type.field.summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.required.element.summary">Required</a>&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.optional.element.summary">Optional</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#annotation.type.field.detail">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.element.detail">Element</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">jakarta.enterprise.concurrent</div>
<h2 title="Annotation Type ContextServiceDefinition" class="title">Annotation Type ContextServiceDefinition</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>@Repeatable(value=<a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.List.html" title="annotation in jakarta.enterprise.concurrent">ContextServiceDefinition.List.class</a>)
@Retention(value=RUNTIME)
@Target(value=TYPE)
public @interface <span class="memberNameLabel">ContextServiceDefinition</span></pre>
<div class="block"><p>Defines a <a href="../../../jakarta/enterprise/concurrent/ContextService.html" title="interface in jakarta.enterprise.concurrent"><code>ContextService</code></a>
to be registered in JNDI by the container
under the JNDI name that is specified in the
<a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#name--"><code>name()</code></a> attribute.</p>
<p>Application components can refer to this JNDI name in the
<a href="../../../jakarta/annotation/Resource.html#lookup--"><code>lookup</code></a> attribute of a
<a href="../../../jakarta/annotation/Resource.html" title="annotation in jakarta.annotation"><code>Resource</code></a> annotation,</p>
<pre> @ContextServiceDefinition(
name = "java:app/concurrent/MyContext",
propagated = APPLICATION,
unchanged = TRANSACTION,
cleared = ALL_REMAINING)
public class MyServlet extends HttpServlet {
@Resource(lookup = "java:app/concurrent/MyContext",
name = "java:app/concurrent/env/MyContextRef")
ContextService appContextSvc;
</pre>
<p>Resource environment references in a deployment descriptor
can similarly specify the <code>lookup-name</code>,</p>
<pre>
&lt;resource-env-ref&gt;
&lt;resource-env-ref-name&gt;java:app/env/concurrent/MyContextRef&lt;/resource-env-ref-name&gt;
&lt;resource-env-ref-type&gt;jakarta.enterprise.concurrent.ContextService&lt;/resource-env-ref-type&gt;
&lt;lookup-name&gt;java:app/concurrent/MyContext&lt;/lookup-name&gt;
&lt;/resource-env-ref&gt;
</pre>
<p>The <a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#cleared--"><code>cleared()</code></a>, <a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#propagated--"><code>propagated()</code></a>, and <a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#unchanged--"><code>unchanged()</code></a>
attributes enable the application to configure how thread context
is applied to tasks and actions that are contextualized by the
<code>ContextService</code>.
Constants are provided on this class for context types that are
defined by the Jakarta EE Concurrency specification.
In addition to those constants, a Jakarta EE product provider
may choose to accept additional vendor-specific context types.
Usage of vendor-specific types will make applications non-portable.</p>
<p>Overlap of the same context type across multiple lists is an error and
prevents the <code>ContextService</code> instance from being created.
If <a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#ALL_REMAINING"><code>ALL_REMAINING</code></a> is not present in any of the lists, it is
implicitly appended to the <a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#cleared--"><code>cleared()</code></a> context types.</p>
You can also define a <code>ContextService</code> with the
<code>&lt;context-service&gt;</code> deployment descriptor element.
For example,
<pre>
&lt;context-service&gt;
&lt;name&gt;java:app/concurrent/MyContext&lt;/name&gt;
&lt;cleared&gt;Security&lt;/cleared&gt;
&lt;cleared&gt;Transaction&lt;/cleared&gt;
&lt;propagated&gt;Application&lt;/propagated&gt;
&lt;unchanged&gt;Remaining&lt;/unchanged&gt;
&lt;/context-service&gt;
</pre>
If a <code>context-service</code> and <code>ContextServiceDefinition</code>
have the same name, their attributes are merged to define a single
<code>ContextService</code> definition, with each attribute that is specified
in the <code>context-service</code> deployment descriptor entry taking
precedence over the corresponding attribute of the annotation.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>3.0</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== ANNOTATION TYPE FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="annotation.type.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">Fields and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#ALL_REMAINING">ALL_REMAINING</a></span></code>
<div class="block">All available thread context types that are not specified
elsewhere.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#APPLICATION">APPLICATION</a></span></code>
<div class="block">Context pertaining to the application component or module,
including its Jakarta EE namespace (such as
<code>java:comp/env/</code>) and thread context class loader.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#SECURITY">SECURITY</a></span></code>
<div class="block">Context that controls the credentials that are associated
with the thread, including the caller subject and
invocation/RunAs subject.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#TRANSACTION">TRANSACTION</a></span></code>
<div class="block">Context that controls the transaction that is associated
with the thread.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- =========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="annotation.type.required.element.summary">
<!-- -->
</a>
<h3>Required Element Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Required Element Summary table, listing required elements, and an explanation">
<caption><span>Required Elements</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Required Element and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#name--">name</a></span></code>
<div class="block">JNDI name of the <a href="../../../jakarta/enterprise/concurrent/ContextService.html" title="interface in jakarta.enterprise.concurrent"><code>ContextService</code></a> instance being defined.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="annotation.type.optional.element.summary">
<!-- -->
</a>
<h3>Optional Element Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Optional Element Summary table, listing optional elements, and an explanation">
<caption><span>Optional Elements</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Optional Element and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.String[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#cleared--">cleared</a></span></code>
<div class="block">Types of context to clear whenever a thread runs the
contextual task or action.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>java.lang.String[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#propagated--">propagated</a></span></code>
<div class="block">Types of context to capture from the requesting thread
and propagate to a thread that runs the contextual task
or action.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.String[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#unchanged--">unchanged</a></span></code>
<div class="block">Types of context that are left alone when a thread
runs the contextual task or action.</div>
</td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ ANNOTATION TYPE FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="annotation.type.field.detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="ALL_REMAINING">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ALL_REMAINING</h4>
<pre>public static final&nbsp;java.lang.String&nbsp;ALL_REMAINING</pre>
<div class="block"><p>All available thread context types that are not specified
elsewhere. This includes thread context types from custom
<a href="../../../jakarta/enterprise/concurrent/spi/ThreadContextProvider.html" title="interface in jakarta.enterprise.concurrent.spi"><code>ThreadContextProviders</code></a>
that are not specified elsewhere.</p>
<p>For example, to define a <code>ContextService</code> that
propagates <a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#SECURITY"><code>SECURITY</code></a> context,
leaves <a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.html#TRANSACTION"><code>TRANSACTION</code></a> context alone,
and clears every other context type:</p>
<pre> @ContextServiceDefinition(
name = "java:module/concurrent/SecurityContext",
propagated = SECURITY,
unchanged = TRANSACTION,
cleared = ALL_REMAINING)
public class MyServlet extends HttpServlet ...
</pre></div>
</li>
</ul>
</li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="APPLICATION">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>APPLICATION</h4>
<pre>public static final&nbsp;java.lang.String&nbsp;APPLICATION</pre>
<div class="block"><p>Context pertaining to the application component or module,
including its Jakarta EE namespace (such as
<code>java:comp/env/</code>) and thread context class loader.</p>
<p>A cleared application context means that the thread is
not associated with any application component and lacks
access to the Jakarta EE namespace and thread context class
loader of the application.</p></div>
</li>
</ul>
</li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="SECURITY">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>SECURITY</h4>
<pre>public static final&nbsp;java.lang.String&nbsp;SECURITY</pre>
<div class="block"><p>Context that controls the credentials that are associated
with the thread, including the caller subject and
invocation/RunAs subject.</p>
<p>A cleared security context gives the thread unauthenticated
subjects.</p></div>
</li>
</ul>
</li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="TRANSACTION">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>TRANSACTION</h4>
<pre>public static final&nbsp;java.lang.String&nbsp;TRANSACTION</pre>
<div class="block"><p>Context that controls the transaction that is associated
with the thread.</p>
<p>When cleared transaction context is applied to a thread,
any global transaction that was previously present there is
first suspended such that the contextual task or action can
begin and manage, as permitted by the container, its own new
<a href="../../../jakarta/transaction/UserTransaction.html" title="interface in jakarta.transaction"><code>UserTransaction</code></a>.
After the contextual task or action completes, the prior
transaction is resumed on the thread. This is equivalent to
the execution property, <a href="../../../jakarta/enterprise/concurrent/ManagedTask.html#TRANSACTION"><code>ManagedTask.TRANSACTION</code></a> with
a value of <a href="../../../jakarta/enterprise/concurrent/ManagedTask.html#SUSPEND"><code>ManagedTask.SUSPEND</code></a>.</p>
<p>The execution property, <a href="../../../jakarta/enterprise/concurrent/ManagedTask.html#TRANSACTION"><code>ManagedTask.TRANSACTION</code></a>,
if specified, takes precedence over the behavior for
transaction context that is specified on the resource
definition annotations.</p>
<p>Jakarta EE providers need not support the propagation
of transactions to other threads and can reject resource
definition annotations that include transaction as a
propagated context.</p></div>
</li>
</ul>
</li>
</ul>
<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="annotation.type.element.detail">
<!-- -->
</a>
<h3>Element Detail</h3>
<a name="name--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>name</h4>
<pre>public abstract&nbsp;java.lang.String&nbsp;name</pre>
<div class="block"><p>JNDI name of the <a href="../../../jakarta/enterprise/concurrent/ContextService.html" title="interface in jakarta.enterprise.concurrent"><code>ContextService</code></a> instance being defined.
The JNDI name must be in a valid Jakarta EE namespace,
such as,</p>
<ul>
<li>java:comp</li>
<li>java:module</li>
<li>java:app</li>
<li>java:global</li>
</ul></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>ContextService</code> JNDI name.</dd>
</dl>
</li>
</ul>
</li>
</ul>
<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="cleared--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>cleared</h4>
<pre>public abstract&nbsp;java.lang.String[]&nbsp;cleared</pre>
<div class="block"><p>Types of context to clear whenever a thread runs the
contextual task or action. The thread's previous context
is restored afterward.
<p>Constants are provided on this class for the context types
that are defined by the Jakarta EE Concurrency specification.</p></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>context types to clear.</dd>
</dl>
<dl>
<dt>Default:</dt>
<dd>"Transaction"</dd>
</dl>
</li>
</ul>
</li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="propagated--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>propagated</h4>
<pre>public abstract&nbsp;java.lang.String[]&nbsp;propagated</pre>
<div class="block"><p>Types of context to capture from the requesting thread
and propagate to a thread that runs the contextual task
or action.
The captured context is re-established when threads
run the contextual task or action, with the respective
thread's previous context being restored afterward.
<p>Constants are provided on this class for the context types
that are defined by the Jakarta EE Concurrency specification.</p></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>context types to capture and propagate.</dd>
</dl>
<dl>
<dt>Default:</dt>
<dd>"Remaining"</dd>
</dl>
</li>
</ul>
</li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="unchanged--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>unchanged</h4>
<pre>public abstract&nbsp;java.lang.String[]&nbsp;unchanged</pre>
<div class="block"><p>Types of context that are left alone when a thread
runs the contextual task or action.
<p>For example, with <code> unchanged = TRANSACTION</code>
if a transaction is started after a function is
contextualized, but before the function is run on the same thread,
the transaction will be active in the contextual function:</p>
<pre>Consumer&lt;String, Integer&gt; updateDB = contextService.contextualConsumer(fn);
&#47;/ later, on another thread
tx.begin();
updateDB.accept("java:comp/env/jdbc/ds1");
&#47;/...additional transactional work
tx.commit();</pre>
<p>Constants are provided on this class for the context types
that are defined by the Jakarta EE Concurrency specification.</p></div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>context types to leave unchanged.</dd>
</dl>
<dl>
<dt>Default:</dt>
<dd>{}</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="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="../../../jakarta/enterprise/concurrent/ContextService.html" title="interface in jakarta.enterprise.concurrent"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../jakarta/enterprise/concurrent/ContextServiceDefinition.List.html" title="annotation in jakarta.enterprise.concurrent"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?jakarta/enterprise/concurrent/ContextServiceDefinition.html" target="_top">Frames</a></li>
<li><a href="ContextServiceDefinition.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><a href="#annotation.type.field.summary">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.required.element.summary">Required</a>&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.optional.element.summary">Optional</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#annotation.type.field.detail">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.element.detail">Element</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>