blob: c2d4022be029f22908ff2d3843dde19cd2a665e6 [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>jakarta.enterprise.event</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="jakarta.enterprise.event";
}
}
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 class="navBarCell1Rev">Package</li>
<li>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/context/spi/package-summary.html">Prev&nbsp;Package</a></li>
<li><a href="../../../jakarta/enterprise/inject/package-summary.html">Next&nbsp;Package</a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?jakarta/enterprise/event/package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.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>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 title="Package" class="title">Package&nbsp;jakarta.enterprise.event</h1>
<div class="docSummary">
<div class="block">Annotations and interfaces relating to events.</div>
</div>
<p>See:&nbsp;<a href="#package.description">Description</a></p>
</div>
<div class="contentContainer">
<ul class="blockList">
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Interface Summary table, listing interfaces, and an explanation">
<caption><span>Interface Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Interface</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../jakarta/enterprise/event/Event.html" title="interface in jakarta.enterprise.event">Event</a>&lt;T&gt;</td>
<td class="colLast">
<div class="block">
Allows the application to fire events of a particular type.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../jakarta/enterprise/event/NotificationOptions.html" title="interface in jakarta.enterprise.event">NotificationOptions</a></td>
<td class="colLast">
<div class="block">Notification options are used to configure observer notification.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../jakarta/enterprise/event/NotificationOptions.Builder.html" title="interface in jakarta.enterprise.event">NotificationOptions.Builder</a></td>
<td class="colLast">
<div class="block">Notification options builder.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation">
<caption><span>Class Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Class</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../jakarta/enterprise/event/Shutdown.html" title="class in jakarta.enterprise.event">Shutdown</a></td>
<td class="colLast">
<div class="block">
A CDI event with payload of type <a href="../../../jakarta/enterprise/event/Shutdown.html" title="class in jakarta.enterprise.event"><code>Shutdown</code></a> and qualifier <a href="../../../jakarta/enterprise/inject/Any.html" title="annotation in jakarta.enterprise.inject"><code>Any</code></a> is
<i>synchronously</i> fired by CDI container during application shutdown.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../jakarta/enterprise/event/Startup.html" title="class in jakarta.enterprise.event">Startup</a></td>
<td class="colLast">
<div class="block">
A CDI event with payload of type <a href="../../../jakarta/enterprise/event/Startup.html" title="class in jakarta.enterprise.event"><code>Startup</code></a> and qualifier <a href="../../../jakarta/enterprise/inject/Any.html" title="annotation in jakarta.enterprise.inject"><code>Any</code></a> is
<i>synchronously</i> fired by CDI container during application initialization.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Enum Summary table, listing enums, and an explanation">
<caption><span>Enum Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Enum</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../jakarta/enterprise/event/Reception.html" title="enum in jakarta.enterprise.event">Reception</a></td>
<td class="colLast">
<div class="block">
Distinguishes conditional <a href="../../../jakarta/enterprise/event/Observes.html" title="annotation in jakarta.enterprise.event">observer methods</a> from observer methods which are
always notified.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../jakarta/enterprise/event/TransactionPhase.html" title="enum in jakarta.enterprise.event">TransactionPhase</a></td>
<td class="colLast">
<div class="block">
Distinguishes the various kinds of transactional <a href="../../../jakarta/enterprise/event/Observes.html" title="annotation in jakarta.enterprise.event">observer methods</a> from regular
observer methods which are notified immediately.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Exception Summary table, listing exceptions, and an explanation">
<caption><span>Exception Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Exception</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../jakarta/enterprise/event/ObserverException.html" title="class in jakarta.enterprise.event">ObserverException</a></td>
<td class="colLast">
<div class="block">
Indicates that a checked exception was thrown by an observer method during event notification.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Annotation Types Summary table, listing annotation types, and an explanation">
<caption><span>Annotation Types Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Annotation Type</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../jakarta/enterprise/event/Observes.html" title="annotation in jakarta.enterprise.event">Observes</a></td>
<td class="colLast">
<div class="block">
Identifies the event parameter of an observer method.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../jakarta/enterprise/event/ObservesAsync.html" title="annotation in jakarta.enterprise.event">ObservesAsync</a></td>
<td class="colLast">
<div class="block">
Identifies the event parameter of an asynchronous observer method.</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
<a name="package.description">
<!-- -->
</a>
<h2 title="Package jakarta.enterprise.event Description">Package jakarta.enterprise.event Description</h2>
<div class="block"><p>Annotations and interfaces relating to events.</p>
<p><a href="../../../jakarta/enterprise/inject/package-summary.html">Beans</a> may produce and
consume events. Events allows beans to interact in a completely
decoupled fashion, with no compile-time dependency between the
interacting beans. Most importantly, it allows stateful beans
in one architectural tier of the application to synchronize
their internal state with state changes that occur in a
different tier.</p>
<p>Events may be fired synchronously or asynchronously.</p>
<p>An event comprises:</p>
<ul>
<li>A Java object, called the event object</li>
<li>A (possibly empty) set of instances of qualifier types, called
the event qualifiers</li>
</ul>
<p>The <a href="../../../jakarta/enterprise/event/Event.html" title="interface in jakarta.enterprise.event"><code>Event</code></a> interface is used to
fire events.</p>
<h3>Event objects and event types</h3>
<p>The event object acts as a payload, to propagate state from
producer to consumer. An event object is an instance of a concrete
Java class with no type variables.</p>
<p>The event types of the event include all superclasses and
interfaces of the runtime class of the event object. An event type
may not contain a type variable.</p>
<h3>Event qualifiers</h3>
<p>The event qualifiers act as topic selectors, allowing the consumer
to narrow the set of events it observes. An event qualifier may be an
instance of any <a href="../../../jakarta/inject/Qualifier.html" title="annotation in jakarta.inject">qualifier type</a>.</p>
<h3>Observer methods</h3>
<p>An <a href="../../../jakarta/enterprise/event/Observes.html" title="annotation in jakarta.enterprise.event">observer method</a>
allows the application to receive and respond synchronously to event notifications.
And an <a href="../../../jakarta/enterprise/event/ObservesAsync.html" title="annotation in jakarta.enterprise.event">async observer method</a>
allows the application to receive and respond asynchronously to event notifications.
they both act as event consumers, observing events of a specific type, with a
specific set of qualifiers. Any Java type may be observed by an
observer method.</p>
<p>An observer method is a method of a bean class or
<a href="../../../jakarta/enterprise/inject/spi/Extension.html" title="interface in jakarta.enterprise.inject.spi">extension</a> with a
parameter annotated <a href="../../../jakarta/enterprise/event/Observes.html" title="annotation in jakarta.enterprise.event"><code>&#064;Observes</code></a>
or <a href="../../../jakarta/enterprise/event/ObservesAsync.html" title="annotation in jakarta.enterprise.event"><code>&#064;ObservesAsync</code></a>.</p>
<p>An observer method will be notified of an event if:</p>
<ul>
<li>the event object is assignable to the type observed by the observer
method,</li>
<li>the observer method has all the event qualifiers of the event, and</li>
<li>either the event is not a
<a href="../../../jakarta/enterprise/inject/spi/package-summary.html">container lifecycle event</a>, or
the observer method belongs to an
<a href="../../../jakarta/enterprise/inject/spi/Extension.html" title="interface in jakarta.enterprise.inject.spi">extension</a>.
</ul>
<p>If a synchronous observer method is a
<a href="../../../jakarta/enterprise/event/TransactionPhase.html" title="enum in jakarta.enterprise.event">transactional
observer method</a> and there is a JTA transaction in progress when the
event is fired, the observer method is notified during the appropriate
transaction completion phase. Otherwise, the observer is notified when
the event is fired.</p>
<p>The order in which observer methods are called depends on the value of
the &#064;<a href="../../../jakarta/annotation/Priority.html" title="annotation in jakarta.annotation">Priority</a> applied to the observer.</p>
<p>If no priority is defined on a observer, its priority is jakarta.interceptor.Interceptor.Priority.APPLICATION+500.</p>
<p>If two observer have the same priority their relative order is undefined.</p>
<p>Observer methods may throw exceptions:</p>
<ul>
<li>If the observer method is a
<a href="../../../jakarta/enterprise/event/TransactionPhase.html" title="enum in jakarta.enterprise.event">transactional
observer method</a>, any exception is caught and logged by the container.</li>
<li>If the observer method is asynchronous, any exception is caught by the container and added as a suppressed exception
to a <code>CompletionException</code> that could be handle by the application</li>
<li>Otherwise, the exception aborts processing of the event.
No other observer methods of that event will be called. The
exception is rethrown. If the exception is a checked exception,
it is wrapped and rethrown as an (unchecked)
<a href="../../../jakarta/enterprise/event/ObserverException.html" title="class in jakarta.enterprise.event"><code>ObserverException</code></a>.</li>
</ul></div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../jakarta/enterprise/inject/package-summary.html"><code>jakarta.enterprise.inject</code></a>,
<a href="../../../jakarta/enterprise/event/Observes.html" title="annotation in jakarta.enterprise.event"><code>Observes</code></a>,
<a href="../../../jakarta/enterprise/event/Event.html" title="interface in jakarta.enterprise.event"><code>Event</code></a>,
<a href="../../../jakarta/inject/Qualifier.html" title="annotation in jakarta.inject"><code>Qualifier</code></a></dd>
</dl>
</div>
<!-- ======= 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 class="navBarCell1Rev">Package</li>
<li>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/context/spi/package-summary.html">Prev&nbsp;Package</a></li>
<li><a href="../../../jakarta/enterprise/inject/package-summary.html">Next&nbsp;Package</a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?jakarta/enterprise/event/package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.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>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>