Author: dblevins
Date: Sun Dec 30 19:02:51 2018
New Revision: 1849998
URL: http://svn.apache.org/viewvc?rev=1849998&view=rev
Log:
Maven update of the website on the Sun Dec 30 11:02:39 PST 2018 from dblevins
Modified:
tomee/site/trunk/content/community/contributors.html
tomee/site/trunk/content/latest/docs/developer/ide/index.html
tomee/site/trunk/content/latest/examples/cdi-application-scope.html
tomee/site/trunk/content/latest/examples/cdi-basic.html
tomee/site/trunk/content/latest/examples/cdi-events.html
tomee/site/trunk/content/latest/examples/cdi-interceptors.html
tomee/site/trunk/content/latest/examples/cdi-produces-disposes.html
tomee/site/trunk/content/latest/examples/cdi-produces-field.html
tomee/site/trunk/content/latest/examples/cdi-request-scope.html
tomee/site/trunk/content/latest/examples/cdi-session-scope.html
tomee/site/trunk/content/latest/examples/index.html
tomee/site/trunk/content/latest/examples/mp-config-example.html
tomee/site/trunk/content/latest/examples/mp-custom-healthcheck.html
tomee/site/trunk/content/latest/examples/mp-faulttolerance-fallback.html
tomee/site/trunk/content/latest/examples/mp-faulttolerance-retry.html
tomee/site/trunk/content/latest/examples/mp-metrics-counted.html
tomee/site/trunk/content/latest/examples/mp-metrics-histogram.html
tomee/site/trunk/content/latest/examples/mp-metrics-metered.html
tomee/site/trunk/content/latest/examples/mp-metrics-timed.html
tomee/site/trunk/content/latest/examples/mp-opentracing-traced.html
tomee/site/trunk/content/latest/examples/mp-rest-client.html
tomee/site/trunk/content/latest/examples/mp-rest-jwt.html
tomee/site/trunk/content/master/docs/developer/ide/index.html
tomee/site/trunk/content/master/examples/cdi-application-scope.html
tomee/site/trunk/content/master/examples/cdi-basic.html
tomee/site/trunk/content/master/examples/cdi-events.html
tomee/site/trunk/content/master/examples/cdi-interceptors.html
tomee/site/trunk/content/master/examples/cdi-produces-disposes.html
tomee/site/trunk/content/master/examples/cdi-produces-field.html
tomee/site/trunk/content/master/examples/cdi-request-scope.html
tomee/site/trunk/content/master/examples/cdi-session-scope.html
tomee/site/trunk/content/master/examples/index.html
tomee/site/trunk/content/master/examples/mp-config-example.html
tomee/site/trunk/content/master/examples/mp-custom-healthcheck.html
tomee/site/trunk/content/master/examples/mp-faulttolerance-fallback.html
tomee/site/trunk/content/master/examples/mp-faulttolerance-retry.html
tomee/site/trunk/content/master/examples/mp-metrics-counted.html
tomee/site/trunk/content/master/examples/mp-metrics-histogram.html
tomee/site/trunk/content/master/examples/mp-metrics-metered.html
tomee/site/trunk/content/master/examples/mp-metrics-timed.html
tomee/site/trunk/content/master/examples/mp-opentracing-traced.html
tomee/site/trunk/content/master/examples/mp-rest-client.html
tomee/site/trunk/content/master/examples/mp-rest-jwt.html
tomee/site/trunk/content/sitemap.xml
tomee/site/trunk/content/tomee-8.0/docs/developer/ide/index.html
tomee/site/trunk/content/tomee-8.0/examples/cdi-application-scope.html
tomee/site/trunk/content/tomee-8.0/examples/cdi-basic.html
tomee/site/trunk/content/tomee-8.0/examples/cdi-events.html
tomee/site/trunk/content/tomee-8.0/examples/cdi-interceptors.html
tomee/site/trunk/content/tomee-8.0/examples/cdi-produces-disposes.html
tomee/site/trunk/content/tomee-8.0/examples/cdi-produces-field.html
tomee/site/trunk/content/tomee-8.0/examples/cdi-request-scope.html
tomee/site/trunk/content/tomee-8.0/examples/cdi-session-scope.html
tomee/site/trunk/content/tomee-8.0/examples/index.html
tomee/site/trunk/content/tomee-8.0/examples/mp-config-example.html
tomee/site/trunk/content/tomee-8.0/examples/mp-custom-healthcheck.html
tomee/site/trunk/content/tomee-8.0/examples/mp-faulttolerance-fallback.html
tomee/site/trunk/content/tomee-8.0/examples/mp-faulttolerance-retry.html
tomee/site/trunk/content/tomee-8.0/examples/mp-metrics-counted.html
tomee/site/trunk/content/tomee-8.0/examples/mp-metrics-histogram.html
tomee/site/trunk/content/tomee-8.0/examples/mp-metrics-metered.html
tomee/site/trunk/content/tomee-8.0/examples/mp-metrics-timed.html
tomee/site/trunk/content/tomee-8.0/examples/mp-opentracing-traced.html
tomee/site/trunk/content/tomee-8.0/examples/mp-rest-client.html
tomee/site/trunk/content/tomee-8.0/examples/mp-rest-jwt.html
Modified: tomee/site/trunk/content/community/contributors.html
URL:
http://svn.apache.org/viewvc/tomee/site/trunk/content/community/contributors.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/community/contributors.html (original)
+++ tomee/site/trunk/content/community/contributors.html Sun Dec 30 19:02:51
2018
@@ -123,6 +123,19 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
+ <img alt="Andy"
src="http://www.gravatar.com/avatar/fea00dfa5f55664b225d9c072d9c6766?s=140"
style="width:140px">
+ <i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
+ </div>
+ <div class="col-sm-7">
+ <h3 class="contributor-name"
style="font-size:1.4em;">Andy</h3>
+ <p></p>
+ <ul class="list-inline">
+
+ </div>
+ </div>
+
+ <div class="col-sm-4">
+ <div class="photo col-sm-5">
<img alt="David Blevins"
src="http://www.gravatar.com/avatar/d46f3fc40e8ecba3bc3b250d5c0d1734?s=140"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
@@ -144,11 +157,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Andy"
src="http://www.gravatar.com/avatar/fea00dfa5f55664b225d9c072d9c6766?s=140"
style="width:140px">
+ <img alt="Mark Struberg"
src="http://www.gravatar.com/avatar/30fae5bce90608fb3df5c018c586aea6?s=140"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Andy</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Mark Struberg</h3>
<p></p>
<ul class="list-inline">
@@ -183,19 +196,6 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Mark Struberg"
src="http://www.gravatar.com/avatar/30fae5bce90608fb3df5c018c586aea6?s=140"
style="width:140px">
- <i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
- </div>
- <div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Mark Struberg</h3>
- <p></p>
- <ul class="list-inline">
-
- </div>
- </div>
-
- <div class="col-sm-4">
- <div class="photo col-sm-5">
<img alt="Romain Manni-Bucau"
src="http://www.gravatar.com/avatar/a8010b78704a70577a7b079f1bc2c981?s=140"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
@@ -247,11 +247,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Kevan Lee Miller"
src="https://twitter.com/kevanmiller/profile_image?size=bigger"
style="width:140px">
+ <img alt="Manu George" src="../img/manugeorge.jpg"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Kevan Lee Miller</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Manu George</h3>
<p></p>
<ul class="list-inline">
@@ -260,11 +260,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Manu George" src="../img/manugeorge.jpg"
style="width:140px">
+ <img alt="Kevan Lee Miller"
src="https://twitter.com/kevanmiller/profile_image?size=bigger"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Manu George</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Kevan Lee Miller</h3>
<p></p>
<ul class="list-inline">
@@ -286,11 +286,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Mohammad Nour El-Din" src="../img/mnour.jpg"
style="width:140px">
+ <img alt="Karan Singh Malhi"
src="https://twitter.com/KrnMal/profile_image?size=bigger" style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Mohammad Nour El-Din</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Karan Singh Malhi</h3>
<p></p>
<ul class="list-inline">
@@ -299,11 +299,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Karan Singh Malhi"
src="https://twitter.com/KrnMal/profile_image?size=bigger" style="width:140px">
+ <img alt="Rick McGuire" src="../img/rickmcguire.jpg"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Karan Singh Malhi</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Rick McGuire</h3>
<p></p>
<ul class="list-inline">
@@ -312,11 +312,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Rick McGuire" src="../img/rickmcguire.jpg"
style="width:140px">
+ <img alt="Mohammad Nour El-Din" src="../img/mnour.jpg"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Rick McGuire</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Mohammad Nour El-Din</h3>
<p></p>
<ul class="list-inline">
@@ -325,11 +325,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Jonathan Gallimore"
src="https://twitter.com/jongallimore/profile_image?size=bigger"
style="width:140px">
+ <img alt="Alan Cabrera"
src="https://twitter.com/maguro/profile_image?size=bigger" style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Jonathan Gallimore</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Alan Cabrera</h3>
<p></p>
<ul class="list-inline">
@@ -338,11 +338,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Alan Cabrera"
src="https://twitter.com/maguro/profile_image?size=bigger" style="width:140px">
+ <img alt="Jonathan Gallimore"
src="https://twitter.com/jongallimore/profile_image?size=bigger"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Alan Cabrera</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Jonathan Gallimore</h3>
<p></p>
<ul class="list-inline">
@@ -351,11 +351,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Jean-Louis Monteiro"
src="https://twitter.com/JLouisMonteiro/profile_image?size=bigger"
style="width:140px">
+ <img alt="Jeff Genender" src="../img/jgenender.jpg"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Jean-Louis Monteiro</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Jeff Genender</h3>
<p></p>
<ul class="list-inline">
@@ -364,11 +364,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Daniel Stefan Haischt"
src="https://twitter.com/uebermodean/profile_image?size=bigger"
style="width:140px">
+ <img alt="Aaron Mulder" src="../img/ammulder.png"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Daniel Stefan Haischt</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Aaron Mulder</h3>
<p></p>
<ul class="list-inline">
@@ -390,11 +390,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Jeff Genender" src="../img/jgenender.jpg"
style="width:140px">
+ <img alt="Jarek Gawor"
src="https://twitter.com/jgawor/profile_image?size=bigger" style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Jeff Genender</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Jarek Gawor</h3>
<p></p>
<ul class="list-inline">
@@ -403,11 +403,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Gianny Damour" src="../img/gdamour.jpg"
style="width:140px">
+ <img alt="Lin Quan Jiang" src="../img/genspring.jpg"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Gianny Damour</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Lin Quan Jiang</h3>
<p></p>
<ul class="list-inline">
@@ -416,11 +416,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Matt Richard Hogstrom"
src="https://twitter.com/hogstrom/profile_image?size=bigger"
style="width:140px">
+ <img alt="David Jencks" src="../img/noimg.png"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Matt Richard Hogstrom</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">David Jencks</h3>
<p></p>
<ul class="list-inline">
@@ -429,11 +429,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Lin Quan Jiang" src="../img/genspring.jpg"
style="width:140px">
+ <img alt="Daniel Stefan Haischt"
src="https://twitter.com/uebermodean/profile_image?size=bigger"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Lin Quan Jiang</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Daniel Stefan Haischt</h3>
<p></p>
<ul class="list-inline">
@@ -442,11 +442,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="David Jencks" src="../img/noimg.png"
style="width:140px">
+ <img alt="Jean-Louis Monteiro"
src="https://twitter.com/JLouisMonteiro/profile_image?size=bigger"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">David Jencks</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Jean-Louis Monteiro</h3>
<p></p>
<ul class="list-inline">
@@ -455,11 +455,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Jarek Gawor"
src="https://twitter.com/jgawor/profile_image?size=bigger" style="width:140px">
+ <img alt="Matt Richard Hogstrom"
src="https://twitter.com/hogstrom/profile_image?size=bigger"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Jarek Gawor</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Matt Richard Hogstrom</h3>
<p></p>
<ul class="list-inline">
@@ -468,11 +468,11 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
- <img alt="Aaron Mulder" src="../img/ammulder.png"
style="width:140px">
+ <img alt="Gianny Damour" src="../img/gdamour.jpg"
style="width:140px">
<i class="pull-right fa fa-star-o"
style="color:#F38F24;"></i>
</div>
<div class="col-sm-7">
- <h3 class="contributor-name"
style="font-size:1.4em;">Aaron Mulder</h3>
+ <h3 class="contributor-name"
style="font-size:1.4em;">Gianny Damour</h3>
<p></p>
<ul class="list-inline">
Modified: tomee/site/trunk/content/latest/docs/developer/ide/index.html
URL:
http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/docs/developer/ide/index.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/latest/docs/developer/ide/index.html (original)
+++ tomee/site/trunk/content/latest/docs/developer/ide/index.html Sun Dec 30
19:02:51 2018
@@ -125,15 +125,15 @@
<h2 id="_eclipse">Eclipse</h2>
<div class="sectionbody">
<div class="paragraph">
-<p>Be the first to write this part!</p>
+<p>Eclipse is an integrated development environment used in computer
programming, and is the most widely used Java IDE. It contains a base workspace
and an extensible plug-in system for customizing the environment. <a
href="https://en.wikipedia.org/wiki/Eclipse_(software)">Wikipedia</a></p>
</div>
</div>
</div>
<div class="sect1">
-<h2 id="_idea">Idea</h2>
+<h2 id="_intellij_idea">IntelliJ IDEA</h2>
<div class="sectionbody">
<div class="paragraph">
-<p>Be the first to write this part!</p>
+<p>IntelliJ IDEA is a Java integrated development environment for developing
computer software. It is developed by JetBrains, and is available as an Apache
2 Licensed community edition, and in a proprietary commercial edition. Both can
be used for commercial development. <a
href="https://en.wikipedia.org/wiki/IntelliJ_IDEA">Wikipedia</a></p>
</div>
</div>
</div>
@@ -141,7 +141,7 @@
<h2 id="_netbeans">Netbeans</h2>
<div class="sectionbody">
<div class="paragraph">
-<p>Be the first to write this part!</p>
+<p>NetBeans is an integrated development environment for Java. NetBeans allows
applications to be developed from a set of modular software components called
modules. NetBeans runs on Microsoft Windows, macOS, Linux and Solaris. <a
href="https://en.wikipedia.org/wiki/NetBeans">Wikipedia</a></p>
</div>
</div>
</div>
Modified: tomee/site/trunk/content/latest/examples/cdi-application-scope.html
URL:
http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/cdi-application-scope.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/latest/examples/cdi-application-scope.html
(original)
+++ tomee/site/trunk/content/latest/examples/cdi-application-scope.html Sun Dec
30 19:02:51 2018
@@ -95,12 +95,33 @@
<div class="row">
<div class="col-md-12">
- <p>This example show the use of
<code>@ApplicationScoped</code> annotation for injected objects. An object
which is defined as <code>@ApplicationScoped</code> is created once for the
duration of the application.</p>
-<h1>Example</h1>
-<p>This example depicts a similar scenario to cdi-request-scope. A restaurant
guest orders a soup from the waiter. The waiter then delivers the soup back to
the guest. Another guest can order the same soup that was ordered by the
previous client - this is where the application scope is used. </p>
-<h2>Waiter</h2>
-<p>The <code>Waiter</code> session bean receives a request from the test class
via the <code>orderSoup()</code> method and sets the name for the
<code>soup</code> field. The <code>orderWhatTheOtherGuyHad()</code> method
returns the name of the <code>soup</code> field.</p>
-<pre><code>@Stateless
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>This example show the use of <code>@ApplicationScoped</code> annotation for
injected objects. An object
+which is defined as <code>@ApplicationScoped</code> is created once for the
duration of the application.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_example">Example</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>This example depicts a similar scenario to cdi-request-scope. A restaurant
guest orders
+a soup from the waiter. The waiter then delivers the soup back to the guest.
Another
+guest can order the same soup that was ordered by the previous client - this
is where
+the application scope is used.</p>
+</div>
+<div class="sect2">
+<h3 id="_waiter">Waiter</h3>
+<div class="paragraph">
+<p>The <code>Waiter</code> session bean receives a request from the test class
via the <code>orderSoup()</code> method
+and sets the name for the <code>soup</code> field. The
<code>orderWhatTheOtherGuyHad()</code> method returns
+the name of the <code>soup</code> field.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Stateless
public class Waiter {
@Inject
@@ -115,18 +136,27 @@ public class Waiter {
String name = soup.getName();
return name;
}
-}
-</code></pre>
-<h2>Soup</h2>
-<p>The <code>Soup</code> class is an injectable POJO, defined as
<code>@ApplicationScoped</code>. This means that an instance will be created
only once for the duration of the whole application. Try changing the
<code>@ApplicationScoped</code> annotation to <code>@RequestScoped</code> and
see what happens.</p>
-<pre><code>@ApplicationScoped
+}</pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_soup">Soup</h3>
+<div class="paragraph">
+<p>The <code>Soup</code> class is an injectable POJO, defined as
<code>@ApplicationScoped</code>. This means that an instance
+will be created only once for the duration of the whole application. Try
changing the <code>@ApplicationScoped</code>
+annotation to <code>@RequestScoped</code> and see what happens.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@ApplicationScoped
public class Soup {
- private String name = "Soup of the day";
+ private String name = "Soup of the day";
@PostConstruct
public void afterCreate() {
- System.out.println("Soup created");
+ System.out.println("Soup created");
}
public String getName() {
@@ -136,13 +166,25 @@ public class Soup {
public void setName(String name){
this.name = name;
}
-}
-</code></pre>
-<h1>Test Case</h1>
-<p>This is the entry class for this example. First a soup is ordered via
<code>orderSoup()</code> method. This initiates the <code>soup</code> field.
Next, <code>orderWhatTheOtherGuyHad()</code> method returns the soup from the
application context.</p>
-<pre><code>public class RestaurantTest {
+}</pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_test_case">Test Case</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>This is the entry class for this example. First a soup is ordered via
<code>orderSoup()</code> method.
+This initiates the <code>soup</code> field. Next,
<code>orderWhatTheOtherGuyHad()</code> method returns the soup
+from the application context.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public class RestaurantTest {
- private static String TOMATO_SOUP = "Tomato Soup";
+ private static String TOMATO_SOUP = "Tomato Soup";
private EJBContainer container;
@EJB
@@ -151,7 +193,7 @@ public class Soup {
@Before
public void startContainer() throws Exception {
container = EJBContainer.createEJBContainer();
- container.getContext().bind("inject", this);
+ container.getContext().bind("inject", this);
}
@Test
@@ -167,11 +209,21 @@ public class Soup {
public void closeContainer() throws Exception {
container.close();
}
-}
-</code></pre>
-<h1>Running</h1>
-<p>In the output you can see that there is just one <code>Soup</code> instance
created - one for the whole application.</p>
-<pre><code>-------------------------------------------------------
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_running">Running</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>In the output you can see that there is just one <code>Soup</code> instance
created - one for
+the whole application.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.superbiz.cdi.applicationscope.RestaurantTest
@@ -179,7 +231,7 @@ Apache OpenEJB 7.0.0-SNAPSHOT build:
http://tomee.apache.org/
INFO - openejb.home =
C:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-application-scope
INFO - openejb.base =
C:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-application-scope
-INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
+INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
INFO - Configuring Service(id=Default Security Service, type=SecurityService,
provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Found EjbModule in classpath:
c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-application-scope\target\classes
@@ -189,10 +241,10 @@ INFO - Configuring Service(id=Default Ma
INFO - Auto-creating a container for bean cdi-application-scope.Comp:
Container(type=MANAGED, id=Default Managed Container)
INFO - Configuring Service(id=Default Stateless Container, type=Container,
provider-id=Default Stateless Container)
INFO - Auto-creating a container for bean Waiter: Container(type=STATELESS,
id=Default Stateless Container)
-INFO - Enterprise application
"c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-application-scope"
loaded.
+INFO - Enterprise application
"c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-application-scope"
loaded.
INFO - Assembling app:
c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-application-scope
-INFO -
Jndi(name="java:global/cdi-application-scope/Waiter!org.superbiz.cdi.applicationscope.Waiter")
-INFO - Jndi(name="java:global/cdi-application-scope/Waiter")
+INFO -
Jndi(name="java:global/cdi-application-scope/Waiter!org.superbiz.cdi.applicationscope.Waiter")
+INFO - Jndi(name="java:global/cdi-application-scope/Waiter")
INFO - Created Ejb(deployment-id=Waiter, ejb-name=Waiter, container=Default
Stateless Container)
INFO - Started Ejb(deployment-id=Waiter, ejb-name=Waiter, container=Default
Stateless Container)
INFO - Deployed
Application(path=c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-application-scope)
@@ -202,8 +254,11 @@ Tests run: 1, Failures: 0, Errors: 0, Sk
Results :
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
-</code></pre>
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</pre>
+</div>
+</div>
+</div>
+</div>
</div>
</div>
Modified: tomee/site/trunk/content/latest/examples/cdi-basic.html
URL:
http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/cdi-basic.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/latest/examples/cdi-basic.html (original)
+++ tomee/site/trunk/content/latest/examples/cdi-basic.html Sun Dec 30 19:02:51
2018
@@ -95,13 +95,48 @@
<div class="row">
<div class="col-md-12">
- <p>To use <code>@Inject</code>, the first thing you need is a
<code>META-INF/beans.xml</code> file in the module or jar. This effectively
turns on CDI and allows the <code>@Inject</code> references to work. No
<code>META-INF/beans.xml</code> no injection, period. This may seem overly
strict, but it is not without reason. The CDI API is a bit greedy and does
consume a fair amount of resources by design.</p>
-<p>When the container constructs a bean with an <code>@Inject</code>
reference, it will first find or create the object that will be injected. For
the sake of simplicity, the is example has a basic <code>Faculty</code> pojo
with a no-arg constructor. Anyone referencing <code>@Inject Faculty</code> will
get their own instance of <code>Faculty</code>. If the desire is to share the
same instance of <code>Faculty</code>, see the concept of <code>scopes</code>
-- this is exactly what scopes are for.</p>
-<h1>Example</h1>
-<p>In this example, we have an <code>@Stateless</code> bean
<code>Course</code> with an <code>@Inject</code> reference to an object of type
<code>Faculty</code>. When <code>Course</code> is created, the container will
also create an instance of <code>Faculty</code>. The
<code>@PostConstruct</code> will be called on the <code>Faculty</code>, then
the <code>Faculty</code> instance will be injected into the <code>Course</code>
bean. Finally, the<br/><code>@PostConstruct</code> will be invoked on
<code>Course</code> and then we're done. All instances will<br/>have been
created.</p>
-<p>The <code>CourseTest</code> test case drives this creation process by
having <code>Course</code> injected in its <code>@Setup</code> method. By the
time our <code>@Test</code> method is invoked, all the real work should be done
and we should be ready to go. In the test case we do some basic asserts to
ensure everything was constructed, all <code>@PostConstruct</code> methods
called and everything injected.</p>
-<h2>Faculty <small>a basic injectable pojo</small></h2>
-<pre><code>public class Faculty {
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>To use <code>@Inject</code>, the first thing you need is a
<code>META-INF/beans.xml</code> file in the module
+or jar. This effectively turns on CDI and allows the <code>@Inject</code>
references to work.
+No <code>META-INF/beans.xml</code> no injection, period. This may seem overly
strict,
+but it is not without reason. The CDI API is a bit greedy and does consume a
fair
+amount of resources by design.</p>
+</div>
+<div class="paragraph">
+<p>When the container constructs a bean with an <code>@Inject</code> reference,
+it will first find or create the object that will be injected. For the sake of
+simplicity, the is example has a basic <code>Faculty</code> pojo with a no-arg
constructor. Anyone
+referencing <code>@Inject Faculty</code> will get their own instance of
<code>Faculty</code>. If the desire
+is to share the same instance of <code>Faculty</code>, see the concept of
<code>scopes</code> — this is
+exactly what scopes are for.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_example">Example</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>In this example, we have an <code>@Stateless</code> bean
<code>Course</code> with an <code>@Inject</code> reference to an
+object of type <code>Faculty</code>. When <code>Course</code> is created, the
container will also create an
+instance of <code>Faculty</code>. The <code>@PostConstruct</code> will be
called on the <code>Faculty</code>,
+then the <code>Faculty</code> instance will be injected into the
<code>Course</code> bean. Finally, the
+<code>@PostConstruct</code> will be invoked on <code>Course</code> and then
we’re done. All instances will
+have been created.</p>
+</div>
+<div class="paragraph">
+<p>The <code>CourseTest</code> test case drives this creation process by
having <code>Course</code> injected
+in its <code>@Setup</code> method. By the time our <code>@Test</code> method
is invoked,
+all the real work should be done and we should be ready to go. In the test
case we do
+some basic asserts to ensure everything was constructed, all
<code>@PostConstruct</code> methods
+called and everything injected.</p>
+</div>
+<div class="sect2">
+<h3 id="_faculty_small_a_basic_injectable_pojo_small">Faculty <small>a basic
injectable pojo</small></h3>
+<div class="literalblock">
+<div class="content">
+<pre>public class Faculty {
private List<String> facultyMembers;
@@ -110,9 +145,9 @@
@PostConstruct
public void initialize() {
this.facultyMembers = new ArrayList<String>();
- facultyMembers.add("Ian Schultz");
- facultyMembers.add("Diane Reyes");
- facultyName = "Computer Science";
+ facultyMembers.add("Ian Schultz");
+ facultyMembers.add("Diane Reyes");
+ facultyName = "Computer Science";
}
public List<String> getFacultyMembers() {
@@ -123,10 +158,15 @@
return facultyName;
}
-}
-</code></pre>
-<h2>Course <small>a simple session bean</small></h2>
-<pre><code>@Stateless
+}</pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_course_small_a_simple_session_bean_small">Course <small>a simple
session bean</small></h3>
+<div class="literalblock">
+<div class="content">
+<pre>@Stateless
public class Course {
@Inject
@@ -141,8 +181,8 @@ public class Course {
assert faculty != null;
// These strings can be externalized
- // We'll see how to do that later
- this.courseName = "CDI 101 - Introduction to CDI";
+ // We'll see how to do that later
+ this.courseName = "CDI 101 - Introduction to CDI";
this.capacity = 100;
}
@@ -157,17 +197,25 @@ public class Course {
public Faculty getFaculty() {
return faculty;
}
-}
-</code></pre>
-<h1>Test Case</h1>
-<pre><code>public class CourseTest extends TestCase {
+}</pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_test_case">Test Case</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>public class CourseTest extends TestCase {
@EJB
private Course course;
@Before
public void setUp() throws Exception {
-
EJBContainer.createEJBContainer().getContext().bind("inject", this);
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
}
@Test
@@ -185,13 +233,20 @@ public class Course {
assertTrue(faculty != null);
// Was the @PostConstruct called on Faculty?
- assertEquals(faculty.getFacultyName(), "Computer Science");
+ assertEquals(faculty.getFacultyName(), "Computer Science");
assertEquals(faculty.getFacultyMembers().size(), 2);
}
-}
-</code></pre>
-<h1>Running</h1>
-<pre><code>-------------------------------------------------------
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_running">Running</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.superbiz.cdi.basic.CourseTest
@@ -199,7 +254,7 @@ Apache OpenEJB 4.0.0-beta-1 build: 20
http://tomee.apache.org/
INFO - openejb.home = /Users/dblevins/examples/cdi-basic
INFO - openejb.base = /Users/dblevins/examples/cdi-basic
-INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
+INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
INFO - Configuring Service(id=Default Security Service, type=SecurityService,
provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Found EjbModule in classpath:
/Users/dblevins/examples/cdi-basic/target/classes
@@ -209,14 +264,14 @@ INFO - Configuring Service(id=Default Ma
INFO - Auto-creating a container for bean cdi-basic.Comp:
Container(type=MANAGED, id=Default Managed Container)
INFO - Configuring Service(id=Default Stateless Container, type=Container,
provider-id=Default Stateless Container)
INFO - Auto-creating a container for bean Course: Container(type=STATELESS,
id=Default Stateless Container)
-INFO - Enterprise application "/Users/dblevins/examples/cdi-basic"
loaded.
+INFO - Enterprise application "/Users/dblevins/examples/cdi-basic" loaded.
INFO - Assembling app: /Users/dblevins/examples/cdi-basic
-INFO -
Jndi(name="java:global/cdi-basic/cdi-basic.Comp!org.apache.openejb.BeanContext$Comp")
-INFO - Jndi(name="java:global/cdi-basic/cdi-basic.Comp")
-INFO -
Jndi(name="java:global/cdi-basic/Course!org.superbiz.cdi.basic.Course")
-INFO - Jndi(name="java:global/cdi-basic/Course")
-INFO -
Jndi(name="java:global/EjbModule1833350875/org.superbiz.cdi.basic.CourseTest!org.superbiz.cdi.basic.CourseTest")
-INFO -
Jndi(name="java:global/EjbModule1833350875/org.superbiz.cdi.basic.CourseTest")
+INFO -
Jndi(name="java:global/cdi-basic/cdi-basic.Comp!org.apache.openejb.BeanContext$Comp")
+INFO - Jndi(name="java:global/cdi-basic/cdi-basic.Comp")
+INFO - Jndi(name="java:global/cdi-basic/Course!org.superbiz.cdi.basic.Course")
+INFO - Jndi(name="java:global/cdi-basic/Course")
+INFO -
Jndi(name="java:global/EjbModule1833350875/org.superbiz.cdi.basic.CourseTest!org.superbiz.cdi.basic.CourseTest")
+INFO -
Jndi(name="java:global/EjbModule1833350875/org.superbiz.cdi.basic.CourseTest")
INFO - Created Ejb(deployment-id=Course, ejb-name=Course, container=Default
Stateless Container)
INFO - Created Ejb(deployment-id=cdi-basic.Comp, ejb-name=cdi-basic.Comp,
container=Default Managed Container)
INFO - Created Ejb(deployment-id=org.superbiz.cdi.basic.CourseTest,
ejb-name=org.superbiz.cdi.basic.CourseTest, container=Default Managed Container)
@@ -228,8 +283,11 @@ Tests run: 1, Failures: 0, Errors: 0, Sk
Results :
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
-</code></pre>
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</pre>
+</div>
+</div>
+</div>
+</div>
</div>
</div>
Modified: tomee/site/trunk/content/latest/examples/cdi-events.html
URL:
http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/cdi-events.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/latest/examples/cdi-events.html (original)
+++ tomee/site/trunk/content/latest/examples/cdi-events.html Sun Dec 30
19:02:51 2018
@@ -88,26 +88,73 @@
<div class="col-md-12">
<div class='page-header'>
- <h1>CDI Events</h1>
+ <h1>CDI Events - Loose Coupling and Extensibility</h1>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
- <h1>CDI events: loose coupling and extensibility</h1>
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
<p>CDI allows you to extend business code by the Notifier/Observer pattern.</p>
-<p>To do it you simply inject a field <code>Event</code> in the notifier
class. This class is a template and the parameter type is the object type to
fire. Then when you want to notify observers you simply call the method fire of
the event object passing as a parameter the event itself<br/>(your own
class!).</p>
-<p>On the other side you annotated a method parameter <code>@Observes</code>
and the parameter type is the sent type by the notifier.</p>
-<p>Note: of course you can add qualifiers to be more precise on your
events.</p>
-<h1>The example</h1>
-<p>The example is pretty simple: an ejb uses the <code>@Schedule</code>
annotation to get a notification each second. The each second this EJB will
send the current date through CDI events.</p>
+</div>
+<div class="paragraph">
+<p>To do it you simply inject a field <code>Event</code> in the notifier
class. This class is a template
+and the parameter type is the object type to fire. Then when you want to
notify observers
+you simply call the method fire of the event object passing as a parameter the
event itself
+(your own class!).</p>
+</div>
+<div class="paragraph">
+<p>On the other side you annotated a method parameter <code>@Observes</code>
and the parameter type is the sent type
+by the notifier.</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<i class="fa icon-note" title="Note"></i>
+</td>
+<td class="content">
+of course you can add qualifiers to be more precise on your events.
+</td>
+</tr>
+</table>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_example">Example</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The example is pretty simple: an ejb uses the <code>@Schedule</code>
annotation to get a notification each second.
+The each second this EJB will send the current date through CDI events.</p>
+</div>
+<div class="paragraph">
<p>This is our "business" code. It is a simple behavior (nothing).</p>
-<p>In our test (which is considered as an extension) we created an observer
(<code>Observer</code> class) which simply store and log each received date.</p>
+</div>
+<div class="paragraph">
+<p>In our test (which is considered as an extension) we created an observer
(<code>Observer</code> class)
+which simply store and log each received date.</p>
+</div>
+<div class="paragraph">
<p>The test itself (<code>EventTest</code>) simply verifies the dates were
received.</p>
-<h1>Conclusion</h1>
-<p>CDI let's you implement very easily plugins through this event mecanism.</p>
-<p>If you go further and look at CDI plugin API you'll realize it is simply
the same kind of events. CDI events is really the basis of CDI.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_conclusion">Conclusion</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>CDI let’s you implement very easily plugins through this event
mecanism.</p>
+</div>
+<div class="paragraph">
+<p>If you go further and look at CDI plugin API you’ll realize it is
simply the same kind
+of events. CDI events is really the basis of CDI.</p>
+</div>
+</div>
+</div>
</div>
</div>
Modified: tomee/site/trunk/content/latest/examples/cdi-interceptors.html
URL:
http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/cdi-interceptors.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/latest/examples/cdi-interceptors.html (original)
+++ tomee/site/trunk/content/latest/examples/cdi-interceptors.html Sun Dec 30
19:02:51 2018
@@ -95,102 +95,186 @@
<div class="row">
<div class="col-md-12">
- <p>Let's write a simple application that would allow us to
book tickets for a movie show. As with all applications, logging is one
cross-cutting concern that we have. Apart from that, there are some methods in
our application, that can be accessed only in the working hours. If accessed at
non-working-hours we'll throw out an AccessDeniedException.</p>
-<p>How do we mark which methods are to be intercepted? Wouldn't it be handy to
annotate a method like</p>
-<pre><code>@Log
-public void aMethod(){...}
-</code></pre>
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Let’s write a simple application that would allow us to book tickets
for a movie show. As with all applications, logging is one cross-cutting
concern that we have. Apart from that, there are some methods in our
application, that can be accessed only in the working hours. If accessed at
non-working-hours we’ll throw out an AccessDeniedException.</p>
+</div>
+<div class="paragraph">
+<p>How do we mark which methods are to be intercepted? Wouldn’t it be
handy to annotate a method like</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Log
+public void aMethod(){...}</pre>
+</div>
+</div>
+<div class="paragraph">
<p>or</p>
-<pre><code>@TimeRestricted
-public void bMethod(){...}
-</code></pre>
-<p>Let's create these annotations that would "mark" a method for
interception.</p>
-<pre><code>@InterceptorBinding
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@TimeRestricted
+public void bMethod(){...}</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Let’s create these annotations that would "mark" a method for
interception.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@InterceptorBinding
@Target({ TYPE, METHOD })
@Retention(RUNTIME)
public @interface Log {
-}
-</code></pre>
+}</pre>
+</div>
+</div>
+<div class="paragraph">
<p>And</p>
-<pre><code>@InterceptorBinding
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@InterceptorBinding
@Target({ TYPE, METHOD })
@Retention(RUNTIME)
public @interface TimeRestricted {
-}
-</code></pre>
-<p>Sure, you haven't missed the <code>@InterceptorBinding</code> annotation
above! Now that our custom annotations are created, lets attach them (or to use
a better term for it, "bind them") to interceptors.</p>
-<p>So here's our logging interceptor. An <code>@AroundInvoke</code> method and
we are almost done.</p>
-<pre><code>@Interceptor
+}</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Sure, you haven’t missed the <code>@InterceptorBinding</code>
annotation above! Now that our custom annotations are created, lets attach them
(or to use a better term for it, "bind them") to interceptors.</p>
+</div>
+<div class="paragraph">
+<p>So here’s our logging interceptor. An <code>@AroundInvoke</code>
method and we are almost done.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Interceptor
@Log //binding the interceptor here. now any method annotated with @Log would
be intercepted by logMethodEntry
public class BookForAShowLoggingInterceptor implements Serializable {
private static final long serialVersionUID = 8139854519874743530L;
- private Logger logger =
Logger.getLogger("BookForAShowApplicationLogger");
+ private Logger logger = Logger.getLogger("BookForAShowApplicationLogger");
@AroundInvoke
public Object logMethodEntry(InvocationContext ctx) throws Exception {
- logger.info("Before entering method:" +
ctx.getMethod().getName());
+ logger.info("Before entering method:" + ctx.getMethod().getName());
InterceptionOrderTracker.getMethodsInterceptedList().add(ctx.getMethod().getName());
InterceptionOrderTracker.getInterceptedByList().add(this.getClass().getSimpleName());
return ctx.proceed();
}
-}
-</code></pre>
+}</pre>
+</div>
+</div>
+<div class="paragraph">
<p>Now the <code>@Log</code> annotation we created is bound to this
interceptor. (Likewise we bind <code>@TimeRestrict</code> for
<code>TimeBasedRestrictingInterceptor</code>. See links below for source)</p>
-<p>That done, let's annotate at class-level or method-level and have fun
intercepting!</p>
-<pre><code>@Log
+</div>
+<div class="paragraph">
+<p>That done, let’s annotate at class-level or method-level and have fun
intercepting!</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Log
@Stateful
public class BookForAShowOneInterceptorApplied implements Serializable {
private static final long serialVersionUID = 6350400892234496909L;
public List<String> getMoviesList() {
List<String> moviesAvailable = new ArrayList<String>();
- moviesAvailable.add("12 Angry Men");
- moviesAvailable.add("Kings speech");
+ moviesAvailable.add("12 Angry Men");
+ moviesAvailable.add("Kings speech");
return moviesAvailable;
}
public Integer getDiscountedPrice(int ticketPrice) {
return ticketPrice - 50;
}
// assume more methods are present
-}
-</code></pre>
+}</pre>
+</div>
+</div>
+<div class="paragraph">
<p>The <code>@Log</code> annotation applied at class level denotes that all
the methods should be intercepted with
<code>BookForAShowLoggingInterceptor</code>.</p>
-<p>Before we say "all done" there's one last thing we are left with! To enable
the interceptors!</p>
+</div>
+<div class="paragraph">
+<p>Before we say "all done" there’s one last thing we are left with! To
enable the interceptors!</p>
+</div>
+<div class="paragraph">
<p>Lets quickly put up a <code>beans.xml</code> file like the following in
<code>src/main/resources/META-INF/beans.xml</code>:</p>
-<pre><code><beans>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre><beans>
<interceptors>
<class>org.superbiz.cdi.bookshow.interceptors.BookForAShowLoggingInterceptor
</class>
<class>org.superbiz.cdi.bookshow.interceptors.TimeBasedRestrictingInterceptor
</class>
</interceptors>
-</beans>
-</code></pre>
-<p>By default, a bean archive has no enabled interceptors; an interceptor must
be explicitly enabled by listing its class in the <code>beans.xml</code>.</p>
-<p>The order of the interceptor annotations has no real significance. Eg:</p>
-<pre><code>@TimeRestrict
+</beans></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>By default, a bean archive has no enabled interceptors; an interceptor must
be explicitly enabled by listing its class
+in the <code>beans.xml</code>.</p>
+</div>
+<div class="paragraph">
+<p>The order of the interceptor annotations has no real significance.
+Eg:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@TimeRestrict
@Log
-void cMethod(){}
-</code></pre>
+void cMethod(){}</pre>
+</div>
+</div>
+<div class="paragraph">
<p>It is the <code>interceptor</code> elements in <code>beans.xml</code> that
not only "enable" the interceptors, but also define the "order of execution" of
the interceptors. In this case the <code>BookForAShowLoggingInterceptor</code>
would be applied first and then <code>TimeBasedRestrictingInterceptor</code></p>
+</div>
+<div class="paragraph">
<p>So now you know that the order is only determined by the order within the
<code>interceptors</code> element within the <code>beans.xml</code>. The rule
is simple, interceptors which occur earlier in the list are called first.</p>
+</div>
+<div class="paragraph">
<p>Also note that a method can be marked for interception using multiple
interceptors by applying multiple annotations as above.</p>
-<p>This brings us to another question. In the above case there were two
interceptors applied together. What if I would require about 4 such
interceptors that would go along.... Having to annotate so much makes the code
a little clumsy?</p>
+</div>
+<div class="paragraph">
+<p>This brings us to another question. In the above case there were two
interceptors applied together. What if I would require about 4 such
interceptors that would go along…​. Having to annotate so much
makes the code a little clumsy?</p>
+</div>
+<div class="paragraph">
<p>No worries! Just create a custom annotation which inherits from others</p>
-<pre><code>@Inherited
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Inherited
@InterceptorBinding
@Target({ TYPE, METHOD })
@Retention(RUNTIME)
@Log
@TimeRestricted
public @interface TimeRestrictAndLog {
-}
-</code></pre>
+}</pre>
+</div>
+</div>
+<div class="paragraph">
<p>This is interceptor binding inheritance.</p>
+</div>
+<div class="paragraph">
<p>The code below demonstrates the many cases that we have discussed.</p>
+</div>
+<div class="paragraph">
<p>Not to forget, the old style binding with
<code>@Interceptors(WhicheverInterceptor.class)</code> is also supported. Have
a look at <code>BookForAShowOldStyleInterceptorBinding</code> where the
comments explain how the newer way discussed above is better.</p>
-<h1>The Code</h1>
-<h2>BookForAShowOneInterceptorApplied</h2>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_code">The Code</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3
id="_bookforashowoneinterceptorapplied">BookForAShowOneInterceptorApplied</h3>
+<div class="paragraph">
<p><code>BookForAShowOneInterceptorApplied</code> shows a simple
<code>@Log</code> interceptor applied.</p>
-<pre><code>package org.superbiz.cdi.bookshow.beans;
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.bookshow.beans;
import org.superbiz.cdi.bookshow.interceptorbinding.Log;
@@ -206,19 +290,26 @@ public class BookForAShowOneInterceptorA
public List<String> getMoviesList() {
List<String> moviesAvailable = new ArrayList<String>();
- moviesAvailable.add("12 Angry Men");
- moviesAvailable.add("Kings speech");
+ moviesAvailable.add("12 Angry Men");
+ moviesAvailable.add("Kings speech");
return moviesAvailable;
}
public Integer getDiscountedPrice(int ticketPrice) {
return ticketPrice - 50;
}
-}
-</code></pre>
-<h2>BookForAShowTwoInterceptorsApplied</h2>
+}</pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3
id="_bookforashowtwointerceptorsapplied">BookForAShowTwoInterceptorsApplied</h3>
+<div class="paragraph">
<p><code>BookForAShowTwoInterceptorsApplied</code> shows both
<code>@Log</code> and <code>@TimeRestricted</code> being applied.</p>
-<pre><code>package org.superbiz.cdi.bookshow.beans;
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.bookshow.beans;
import org.superbiz.cdi.bookshow.interceptorbinding.Log;
import org.superbiz.cdi.bookshow.interceptorbinding.TimeRestricted;
@@ -235,8 +326,8 @@ public class BookForAShowTwoInterceptors
public List<String> getMoviesList() {
List<String> moviesAvailable = new ArrayList<String>();
- moviesAvailable.add("12 Angry Men");
- moviesAvailable.add("Kings speech");
+ moviesAvailable.add("12 Angry Men");
+ moviesAvailable.add("Kings speech");
return moviesAvailable;
}
@@ -244,11 +335,18 @@ public class BookForAShowTwoInterceptors
public Integer getDiscountedPrice(int ticketPrice) {
return ticketPrice - 50;
}
-}
-</code></pre>
-<h2>BookShowInterceptorBindingInheritanceExplored</h2>
-<p><code>BookShowInterceptorBindingInheritanceExplored</code> shows how
<code>@TimeRestrictAndLog</code> (interceptor-binding-inheritance) can be used
as an alternative for annotating a method with multiple annotations
explicitly.</p>
-<pre><code>package org.superbiz.cdi.bookshow.beans;
+}</pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3
id="_bookshowinterceptorbindinginheritanceexplored">BookShowInterceptorBindingInheritanceExplored</h3>
+<div class="paragraph">
+<p><code>BookShowInterceptorBindingInheritanceExplored</code> shows how
<code>@TimeRestrictAndLog</code> (interceptor-binding-inheritance) can be used
as an alternative for annotating a method with multiple annotations
explicitly.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.bookshow.beans;
import org.superbiz.cdi.bookshow.interceptorbinding.TimeRestrictAndLog;
@@ -263,8 +361,8 @@ public class BookShowInterceptorBindingI
public List<String> getMoviesList() {
List<String> moviesAvailable = new ArrayList<String>();
- moviesAvailable.add("12 Angry Men");
- moviesAvailable.add("Kings speech");
+ moviesAvailable.add("12 Angry Men");
+ moviesAvailable.add("Kings speech");
return moviesAvailable;
}
@@ -272,8 +370,12 @@ public class BookShowInterceptorBindingI
public Integer getDiscountedPrice(int ticketPrice) {
return ticketPrice - 50;
}
-}
-</code></pre>
+}</pre>
+</div>
+</div>
+</div>
+</div>
+</div>
</div>
</div>
Modified: tomee/site/trunk/content/latest/examples/cdi-produces-disposes.html
URL:
http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/cdi-produces-disposes.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/latest/examples/cdi-produces-disposes.html
(original)
+++ tomee/site/trunk/content/latest/examples/cdi-produces-disposes.html Sun Dec
30 19:02:51 2018
@@ -95,16 +95,42 @@
<div class="row">
<div class="col-md-12">
- <p>This example shows how the @Produces and @Disposes
annotations work. A LogFactory creates an instance of the LogHandler depending
on a "type" attribute. For the purposes of this example, the type is hard-coded
to a specific value. A Logger implementation shall contain a list of
LogHandlers. We shall have three implementations of the LogHandler
interface.</p>
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>This example shows how the @Produces and @Disposes annotations work. A
LogFactory creates an instance of the LogHandler
+depending on a "type" attribute. For the purposes of this example, the type is
hard-coded to a specific value.
+A Logger implementation shall contain a list of LogHandlers. We shall have
three implementations of the LogHandler interface.</p>
+</div>
+<div class="ulist">
<ul>
- <li>A DatabaseHandler</li>
- <li>A FileHandler</li>
- <li>A ConsoleHandler</li>
+<li>
+<p>A DatabaseHandler</p>
+</li>
+<li>
+<p>A FileHandler</p>
+</li>
+<li>
+<p>A ConsoleHandler</p>
+</li>
</ul>
-<p>The DatabaseHandler would seemingly write the logs to a database. The
FileHandler would write the same logs to a file. The ConsoleHandler would just
print the logs to a console (Standard out). This example is just an
illustration of how the concepts within CDI work and is not intended to provide
a logging framework design/implementation.</p>
+</div>
+<div class="paragraph">
+<p>The DatabaseHandler would seemingly write the logs to a database. The
FileHandler would write the same logs to a file.
+The ConsoleHandler would just print the logs to a console (Standard out). This
example is just an illustration of how
+the concepts within CDI work and is not intended to provide a logging
framework design/implementation.</p>
+</div>
+<div class="paragraph">
<p><em>Help us finish documenting this example! Click the blue pencil icon in
the upper right to edit this page.</em></p>
-<h2>ConsoleHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_consolehandler">ConsoleHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
public class ConsoleHandler implements LogHandler {
@@ -121,12 +147,19 @@ public class ConsoleHandler implements L
@Override
public void writeLog(String s) {
- System.out.printf("##### Handler: %s, Writing to the
console!\n", getName());
+ System.out.printf("##### Handler: %s, Writing to the console!\n",
getName());
}
-}
-</code></pre>
-<h2>DatabaseHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_databasehandler">DatabaseHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
public class DatabaseHandler implements LogHandler {
@@ -143,13 +176,20 @@ public class DatabaseHandler implements
@Override
public void writeLog(String s) {
- System.out.printf("##### Handler: %s, Writing to the
database!\n", getName());
+ System.out.printf("##### Handler: %s, Writing to the database!\n",
getName());
// Use connection to write log to database
}
-}
-</code></pre>
-<h2>FileHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_filehandler">FileHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
public class FileHandler implements LogHandler {
@@ -166,13 +206,20 @@ public class FileHandler implements LogH
@Override
public void writeLog(String s) {
- System.out.printf("##### Handler: %s, Writing to the
file!\n", getName());
+ System.out.printf("##### Handler: %s, Writing to the file!\n",
getName());
// Write to log file
}
-}
-</code></pre>
-<h2>LogFactory</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_logfactory">LogFactory</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
@@ -185,47 +232,61 @@ public class LogFactory {
public LogHandler getLogHandler() {
switch (type) {
case 1:
- return new FileHandler("@Produces created
FileHandler!");
+ return new FileHandler("@Produces created FileHandler!");
case 2:
- return new DatabaseHandler("@Produces created
DatabaseHandler!");
+ return new DatabaseHandler("@Produces created
DatabaseHandler!");
case 3:
default:
- return new ConsoleHandler("@Produces created
ConsoleHandler!");
+ return new ConsoleHandler("@Produces created ConsoleHandler!");
}
}
public void closeLogHandler(@Disposes LogHandler handler) {
switch (type) {
case 1:
- System.out.println("Closing File handler!");
+ System.out.println("Closing File handler!");
break;
case 2:
- System.out.println("Closing DB handler!");
+ System.out.println("Closing DB handler!");
break;
case 3:
default:
- System.out.println("Closing Console handler!");
+ System.out.println("Closing Console handler!");
}
}
-}
-</code></pre>
-<h2>Logger</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_logger">Logger</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
public interface Logger {
public void log(String s);
public LogHandler getHandler();
-}
-</code></pre>
-<h2>LoggerImpl</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loggerimpl">LoggerImpl</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
import javax.inject.Inject;
import javax.inject.Named;
-@Named("logger")
+@Named("logger")
public class LoggerImpl implements Logger {
@Inject
@@ -239,27 +300,48 @@ public class LoggerImpl implements Logge
public LogHandler getHandler() {
return handler;
}
-}
-</code></pre>
-<h2>LogHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loghandler">LogHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
public interface LogHandler {
public String getName();
public void writeLog(String s);
-}
-</code></pre>
-<h2>beans.xml</h2>
-<pre><code><beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
-
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
-
-</beans>
-</code></pre>
-<h2>LoggerTest</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_beans_xml">beans.xml</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre><beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+
+</beans></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loggertest">LoggerTest</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
import org.junit.After;
import org.junit.Before;
@@ -284,7 +366,7 @@ public class LoggerTest {
public void setUp() {
try {
ctxt = EJBContainer.createEJBContainer().getContext();
- ctxt.bind("inject", this);
+ ctxt.bind("inject", this);
} catch (Exception e) {
e.printStackTrace();
}
@@ -293,7 +375,7 @@ public class LoggerTest {
@After
public void cleanUp() {
try {
- ctxt.unbind("inject");
+ ctxt.unbind("inject");
ctxt.close();
} catch (Exception e) {
e.printStackTrace();
@@ -303,17 +385,22 @@ public class LoggerTest {
@Test
public void testLogHandler() {
assertNotNull(logger);
- assertFalse("Handler should not be a ConsoleHandler",
logger.getHandler() instanceof ConsoleHandler);
- assertFalse("Handler should not be a FileHandler",
logger.getHandler() instanceof FileHandler);
- assertTrue("Handler should be a DatabaseHandler",
logger.getHandler() instanceof DatabaseHandler);
- logger.log("##### Testing write\n");
+ assertFalse("Handler should not be a ConsoleHandler",
logger.getHandler() instanceof ConsoleHandler);
+ assertFalse("Handler should not be a FileHandler", logger.getHandler()
instanceof FileHandler);
+ assertTrue("Handler should be a DatabaseHandler", logger.getHandler()
instanceof DatabaseHandler);
+ logger.log("##### Testing write\n");
logger = null;
}
-}
-</code></pre>
-<h1>Running</h1>
-<pre><code>-------------------------------------------------------
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="literalblock">
+<div class="content">
+<pre>-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.superbiz.cdi.produces.disposes.LoggerTest
@@ -321,7 +408,7 @@ Apache OpenEJB 4.0.0-beta-1 build: 20
http://tomee.apache.org/
INFO - openejb.home = /Users/dblevins/examples/cdi-produces-disposes
INFO - openejb.base = /Users/dblevins/examples/cdi-produces-disposes
-INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
+INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
INFO - Configuring Service(id=Default Security Service, type=SecurityService,
provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Found EjbModule in classpath:
/Users/dblevins/examples/cdi-produces-disposes/target/classes
@@ -329,12 +416,12 @@ INFO - Beginning load: /Users/dblevins/e
INFO - Configuring enterprise application:
/Users/dblevins/examples/cdi-produces-disposes
INFO - Configuring Service(id=Default Managed Container, type=Container,
provider-id=Default Managed Container)
INFO - Auto-creating a container for bean cdi-produces-disposes.Comp:
Container(type=MANAGED, id=Default Managed Container)
-INFO - Enterprise application
"/Users/dblevins/examples/cdi-produces-disposes" loaded.
+INFO - Enterprise application "/Users/dblevins/examples/cdi-produces-disposes"
loaded.
INFO - Assembling app: /Users/dblevins/examples/cdi-produces-disposes
-INFO -
Jndi(name="java:global/cdi-produces-disposes/cdi-produces-disposes.Comp!org.apache.openejb.BeanContext$Comp")
-INFO -
Jndi(name="java:global/cdi-produces-disposes/cdi-produces-disposes.Comp")
-INFO -
Jndi(name="java:global/EjbModule10202458/org.superbiz.cdi.produces.disposes.LoggerTest!org.superbiz.cdi.produces.disposes.LoggerTest")
-INFO -
Jndi(name="java:global/EjbModule10202458/org.superbiz.cdi.produces.disposes.LoggerTest")
+INFO -
Jndi(name="java:global/cdi-produces-disposes/cdi-produces-disposes.Comp!org.apache.openejb.BeanContext$Comp")
+INFO -
Jndi(name="java:global/cdi-produces-disposes/cdi-produces-disposes.Comp")
+INFO -
Jndi(name="java:global/EjbModule10202458/org.superbiz.cdi.produces.disposes.LoggerTest!org.superbiz.cdi.produces.disposes.LoggerTest")
+INFO -
Jndi(name="java:global/EjbModule10202458/org.superbiz.cdi.produces.disposes.LoggerTest")
INFO - Created Ejb(deployment-id=cdi-produces-disposes.Comp,
ejb-name=cdi-produces-disposes.Comp, container=Default Managed Container)
INFO - Created
Ejb(deployment-id=org.superbiz.cdi.produces.disposes.LoggerTest,
ejb-name=org.superbiz.cdi.produces.disposes.LoggerTest, container=Default
Managed Container)
INFO - Started Ejb(deployment-id=cdi-produces-disposes.Comp,
ejb-name=cdi-produces-disposes.Comp, container=Default Managed Container)
@@ -345,8 +432,9 @@ Tests run: 1, Failures: 0, Errors: 0, Sk
Results :
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
-</code></pre>
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</pre>
+</div>
+</div>
</div>
</div>
Modified: tomee/site/trunk/content/latest/examples/cdi-produces-field.html
URL:
http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/cdi-produces-field.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/latest/examples/cdi-produces-field.html (original)
+++ tomee/site/trunk/content/latest/examples/cdi-produces-field.html Sun Dec 30
19:02:51 2018
@@ -88,23 +88,52 @@
<div class="col-md-12">
<div class='page-header'>
- <h1>CDI field producer</h1>
+ <h1>CDI Field Producer</h1>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
- <p>This example shows the usage of the @Produces annotation.
@Produces is a CDI mechanism which allows defining a source<br/> for injection.
This example shows one of two ways of declaring a producer. Instead of a
producer method (see CDI-produces-disposes example)<br/>a producer field can be
used. A producer field can be used instead of a simple getter method. It could
be used to inject resources, such as persistence contexts. One caveat to using
producer fields over producer<br/> methods is that a @Disposes method cannot be
used in conjunction with @Produces field.</p>
-<p>For the purposes of this example, the type is hard-coded to a specific
value. A Logger implementation shall contain a list of LogHandlers. We shall
have three implementations of the LogHandler interface.</p>
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>This example shows the usage of the @Produces annotation. @Produces is a
CDI mechanism which allows defining a source
+ for injection. This example shows one of two ways of declaring a producer.
Instead of a producer method (see CDI-produces-disposes example)
+a producer field can be used. A producer field can be used instead of a simple
getter method. It could be used to
+inject resources, such as persistence contexts. One caveat to using producer
fields over producer
+ methods is that a @Disposes method cannot be used in conjunction with
@Produces field.</p>
+</div>
+<div class="paragraph">
+<p>For the purposes of this example, the type is hard-coded to a specific
value.
+A Logger implementation shall contain a list of LogHandlers. We shall have
three implementations of the LogHandler interface.</p>
+</div>
+<div class="ulist">
<ul>
- <li>A DatabaseHandler</li>
- <li>A FileHandler</li>
- <li>A ConsoleHandler</li>
+<li>
+<p>A DatabaseHandler</p>
+</li>
+<li>
+<p>A FileHandler</p>
+</li>
+<li>
+<p>A ConsoleHandler</p>
+</li>
</ul>
-<p>The DatabaseHandler would seemingly write the logs to a database. The
FileHandler would write the same logs to a file. The ConsoleHandler would just
print the logs to a console (Standard out). This example is just an
illustration of how the concepts within CDI work and is not intended to provide
a logging framework design/implementation.</p>
-<h2>ConsoleHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+</div>
+<div class="paragraph">
+<p>The DatabaseHandler would seemingly write the logs to a database. The
FileHandler would write the same logs to a file.
+The ConsoleHandler would just print the logs to a console (Standard out). This
example is just an illustration of how
+the concepts within CDI work and is not intended to provide a logging
framework design/implementation.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_consolehandler">ConsoleHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
public class ConsoleHandler implements LogHandler {
@@ -121,12 +150,19 @@ public class ConsoleHandler implements L
@Override
public void writeLog(String s) {
- System.out.printf("##### Handler: %s, Writing to the
console!\n", getName());
+ System.out.printf("##### Handler: %s, Writing to the console!\n",
getName());
}
-}
-</code></pre>
-<h2>DatabaseHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_databasehandler">DatabaseHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
public class DatabaseHandler implements LogHandler {
@@ -143,13 +179,20 @@ public class DatabaseHandler implements
@Override
public void writeLog(String s) {
- System.out.printf("##### Handler: %s, Writing to the
database!\n", getName());
+ System.out.printf("##### Handler: %s, Writing to the database!\n",
getName());
// Use connection to write log to database
}
-}
-</code></pre>
-<h2>FileHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_filehandler">FileHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
public class FileHandler implements LogHandler {
@@ -166,13 +209,20 @@ public class FileHandler implements LogH
@Override
public void writeLog(String s) {
- System.out.printf("##### Handler: %s, Writing to the
file!\n", getName());
+ System.out.printf("##### Handler: %s, Writing to the file!\n",
getName());
// Write to log file
}
-}
-</code></pre>
-<h2>LogFactory</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_logfactory">LogFactory</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
import javax.enterprise.inject.Produces;
@@ -184,40 +234,54 @@ public class LogFactory {
LogHandler handler;
public LogFactory(){
- handler = getLogHandler();
+ handler = getLogHandler();
}
public LogHandler getLogHandler() {
switch (type) {
case 1:
- return new FileHandler("@Produces created
FileHandler!");
+ return new FileHandler("@Produces created FileHandler!");
case 2:
- return new DatabaseHandler("@Produces created
DatabaseHandler!");
+ return new DatabaseHandler("@Produces created
DatabaseHandler!");
case 3:
default:
- return new ConsoleHandler("@Produces created
ConsoleHandler!");
+ return new ConsoleHandler("@Produces created ConsoleHandler!");
}
}
-}
-</code></pre>
-<h2>Logger</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_logger">Logger</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
public interface Logger {
public void log(String s);
public LogHandler getHandler();
-}
-</code></pre>
-<h2>LoggerImpl</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loggerimpl">LoggerImpl</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
import javax.inject.Inject;
import javax.inject.Named;
-@Named("logger")
+@Named("logger")
public class LoggerImpl implements Logger {
@Inject
@@ -231,27 +295,48 @@ public class LoggerImpl implements Logge
public LogHandler getHandler() {
return handler;
}
-}
-</code></pre>
-<h2>LogHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loghandler">LogHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
public interface LogHandler {
public String getName();
public void writeLog(String s);
-}
-</code></pre>
-<h2>beans.xml</h2>
-<pre><code><beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
-
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
-
-</beans>
-</code></pre>
-<h2>LoggerTest</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_beans_xml">beans.xml</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre><beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+
+</beans></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loggertest">LoggerTest</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
import org.junit.After;
import org.junit.Before;
@@ -276,7 +361,7 @@ public class LoggerTest {
public void setUp() {
try {
ctxt = EJBContainer.createEJBContainer().getContext();
- ctxt.bind("inject", this);
+ ctxt.bind("inject", this);
} catch (Exception e) {
e.printStackTrace();
}
@@ -285,7 +370,7 @@ public class LoggerTest {
@After
public void cleanUp() {
try {
- ctxt.unbind("inject");
+ ctxt.unbind("inject");
ctxt.close();
} catch (Exception e) {
e.printStackTrace();
@@ -295,17 +380,22 @@ public class LoggerTest {
@Test
public void testLogHandler() {
assertNotNull(logger);
- assertFalse("Handler should not be a ConsoleHandler",
logger.getHandler() instanceof ConsoleHandler);
- assertFalse("Handler should not be a FileHandler",
logger.getHandler() instanceof FileHandler);
- assertTrue("Handler should be a DatabaseHandler",
logger.getHandler() instanceof DatabaseHandler);
- logger.log("##### Testing write\n");
+ assertFalse("Handler should not be a ConsoleHandler",
logger.getHandler() instanceof ConsoleHandler);
+ assertFalse("Handler should not be a FileHandler", logger.getHandler()
instanceof FileHandler);
+ assertTrue("Handler should be a DatabaseHandler", logger.getHandler()
instanceof DatabaseHandler);
+ logger.log("##### Testing write\n");
logger = null;
}
-}
-</code></pre>
-<h1>Running</h1>
-<pre><code>-------------------------------------------------------
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="literalblock">
+<div class="content">
+<pre>-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.superbiz.cdi.produces.field.LoggerTest
@@ -321,13 +411,13 @@ INFO - openejb.home = /home/daniel/proje
INFO - openejb.base =
/home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
INFO - Created new singletonService
org.apache.openejb.cdi.ThreadSingletonServiceImpl@a81b1fb
INFO - succeeded in installing singleton service
-INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
+INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
INFO - Cannot find the configuration file [conf/openejb.xml]. Will attempt to
create one for the beans deployed.
INFO - Configuring Service(id=Default Security Service, type=SecurityService,
provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Creating TransactionManager(id=Default Transaction Manager)
INFO - Creating SecurityService(id=Default Security Service)
-INFO - Inspecting classpath for applications: 26 urls. Consider adjusting your
exclude/include. Current settings:
openejb.deployments.classpath.exclude='',
openejb.deployments.classpath.include='.*'
+INFO - Inspecting classpath for applications: 26 urls. Consider adjusting your
exclude/include. Current settings: openejb.deployments.classpath.exclude='',
openejb.deployments.classpath.include='.*'
INFO - Searched 26 classpath urls in 2015 milliseconds. Average 77
milliseconds per url.
INFO - Beginning load:
/home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field/target/classes
INFO - Configuring enterprise application:
/home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
@@ -336,7 +426,7 @@ INFO - Configuring Service(id=Default Ma
INFO - Auto-creating a container for bean cdi-produces-field.Comp:
Container(type=MANAGED, id=Default Managed Container)
INFO - Creating Container(id=Default Managed Container)
INFO - Using directory /tmp for stateful session passivation
-INFO - Enterprise application
"/home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field"
loaded.
+INFO - Enterprise application
"/home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field"
loaded.
INFO - Assembling app:
/home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
INFO - ignoreXmlConfiguration == true
INFO - ignoreXmlConfiguration == true
@@ -352,8 +442,9 @@ Tests run: 1, Failures: 0, Errors: 0, Sk
Results :
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
-</code></pre>
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</pre>
+</div>
+</div>
</div>
</div>